Skip to content

Instantly share code, notes, and snippets.

@doesterr
Created May 27, 2014 19:04
Show Gist options
  • Save doesterr/0b7db47af69286bad4c6 to your computer and use it in GitHub Desktop.
Save doesterr/0b7db47af69286bad4c6 to your computer and use it in GitHub Desktop.
def coerce(other)
unless other.is_a?(Numeric)
raise TypeError, "Can't coerce #{other}"
end
operator = caller.first.scan(/`(.*)'/).first.first.to_sym
return [Feet.new(other), self] if operator == :*
raise TypeError "Can't coerce #{other} for operator '#{operator}'"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment