Class: Unite::Quantity
- Inherits:
-
Object
- Object
- Unite::Quantity
- Includes:
- Arithmetic, Conversion, Dimension::Vector
- Defined in:
- lib/unite/quantity.rb
Instance Attribute Summary collapse
-
#cached_expression ⇒ Object
Returns the value of attribute cached_expression.
-
#denominator ⇒ Object
Returns the value of attribute denominator.
-
#name ⇒ Object
Returns the value of attribute name.
-
#numerator ⇒ Object
Returns the value of attribute numerator.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
-
.init(value, unit = "") ⇒ Object
Initialize the quantity,.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Quantity
constructor
A new instance of Quantity.
Methods included from Arithmetic
Methods included from Conversion
Methods included from Fraction
#expanded_denominator, #expanded_numerator, #expression, #expression=, #inverse, #reduce, #unit
Methods included from Comparison
#==, #compatible!, #compatible?, #compatible_units
Methods included from Dimension::Integer
#dimension_int, #property, #property_name
Methods included from Dimension::Vector
Constructor Details
#initialize(attributes = {}) ⇒ Quantity
Returns a new instance of Quantity.
9 10 11 12 13 14 |
# File 'lib/unite/quantity.rb', line 9 def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end super end |
Instance Attribute Details
#cached_expression ⇒ Object
Returns the value of attribute cached_expression.
24 25 26 |
# File 'lib/unite/quantity.rb', line 24 def cached_expression @cached_expression end |
#denominator ⇒ Object
Returns the value of attribute denominator.
24 25 26 |
# File 'lib/unite/quantity.rb', line 24 def denominator @denominator end |
#name ⇒ Object
Returns the value of attribute name.
24 25 26 |
# File 'lib/unite/quantity.rb', line 24 def name @name end |
#numerator ⇒ Object
Returns the value of attribute numerator.
24 25 26 |
# File 'lib/unite/quantity.rb', line 24 def numerator @numerator end |
#value ⇒ Object
Returns the value of attribute value.
24 25 26 |
# File 'lib/unite/quantity.rb', line 24 def value @value end |
Class Method Details
.init(value, unit = "") ⇒ Object
Initialize the quantity,
A nil value is treated as 0.0
20 21 22 |
# File 'lib/unite/quantity.rb', line 20 def self.init value, unit = "" new :expression => [value || 0.0, unit].reject(&:blank?).join('*') end |