Module: Unity::Conversion

Extended by:
ActiveSupport::Concern
Includes:
Comparison, Fraction
Included in:
Arithmetic, DerivedUnit, Property, Quantity
Defined in:
lib/unity/conversion.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Fraction

#expanded_denominator, #expanded_numerator, #expression, #expression=, #initialize, #inverse, #reduce, #unit

Methods included from Comparison

#==, #compatible!, #compatible?

Methods included from Dimension::Integer

#dimension_int, #property, #property_name

Instance Method Details

#convert_to(other) ⇒ Object



20
21
22
23
24
25
# File 'lib/unity/conversion.rb', line 20

def convert_to other
  other = other.clone.tap{|o| o.value = 1.0 }  #this is so that only the unit is used for the conversion 
  new_value = self.converted_value(other)
  return nil if new_value.nil?
  self.class.new :value => new_value, :numerator => other.numerator, :denominator => other.denominator
end