Class: Quantity::QuantityInfo

Inherits:
Object
  • Object
show all
Includes:
CalculationSupport
Defined in:
lib/unitmanager/quantity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CalculationSupport

#==, #coerce, #method_missing

Methods included from Quantifiable

#quantifiable?

Constructor Details

#initialize(value, unit_sym) ⇒ QuantityInfo

Returns a new instance of QuantityInfo.



61
62
63
64
# File 'lib/unitmanager/quantity.rb', line 61

def initialize(value, unit_sym)
  @value = value
  @unit_sym = unit_sym
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Quantity::CalculationSupport

Instance Attribute Details

#unit_symObject (readonly)

Returns the value of attribute unit_sym.



59
60
61
# File 'lib/unitmanager/quantity.rb', line 59

def unit_sym
  @unit_sym
end

#valueObject (readonly)

Returns the value of attribute value.



59
60
61
# File 'lib/unitmanager/quantity.rb', line 59

def value
  @value
end

Instance Method Details

#to_quantity(calc) ⇒ Object



66
67
68
# File 'lib/unitmanager/quantity.rb', line 66

def to_quantity(calc)
  calc.quantity(@value, @unit_sym)
end