lib/unit/class.rb
# Given another object and an operator, use the other object's #coerce method
# to perform the operation.
#
# Based on Matrix#apply_through_coercion
Given another object and an operator, use the other object's #coerce method
to perform the operation.


Given another object and an operator use the other object ' s #coerce method to perform the operation .
def apply_through_coercion(obj, oper)
    coercion = obj.coerce(self)
    raise TypeError unless coercion.is_a?(Array) && coercion.length == 2
    first, last = coercion
    first.send(oper, last)
  rescue
    raise TypeError, "#{obj.class} can't be coerced into #{self.class}"
  end
def apply_through_coercion ( obj , oper ) coercion = obj . coerce ( self ) raise TypeError unless coercion . is_a? ( Array ) && coercion . length == 2 first , last = coercion first . send ( oper , last ) rescue raise TypeError , "#{obj.class} can't be coerced into #{self.class}" end
Given another object and an operator, use the other object's #coerce method
to perform the operation.
Given another object and an operator use the other object ' s #coerce method to perform the operation .
obj
oper