Class: Unite::Unit
- Inherits:
-
Object
- Object
- Unite::Unit
- Includes:
- Comparison, Dimension::Vector, SiFactor
- Defined in:
- lib/unite/unit.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.
Class Method Summary collapse
-
.init(unit) ⇒ Object
Initialize the quantity,.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Unit
constructor
A new instance of Unit.
- #value ⇒ Object
- #value=(x) ⇒ Object
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 = {}) ⇒ Unit
Returns a new instance of Unit.
9 10 11 12 13 14 |
# File 'lib/unite/unit.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.
23 24 25 |
# File 'lib/unite/unit.rb', line 23 def cached_expression @cached_expression end |
#denominator ⇒ Object
Returns the value of attribute denominator.
23 24 25 |
# File 'lib/unite/unit.rb', line 23 def denominator @denominator end |
#name ⇒ Object
Returns the value of attribute name.
23 24 25 |
# File 'lib/unite/unit.rb', line 23 def name @name end |
#numerator ⇒ Object
Returns the value of attribute numerator.
23 24 25 |
# File 'lib/unite/unit.rb', line 23 def numerator @numerator end |
Class Method Details
.init(unit) ⇒ Object
Initialize the quantity,
A nil value is treated as 0.0
19 20 21 |
# File 'lib/unite/unit.rb', line 19 def self.init unit new :expression => "#{unit}" end |
Instance Method Details
#value ⇒ Object
26 27 28 |
# File 'lib/unite/unit.rb', line 26 def value @value ||= BigDecimal.new(1) end |
#value=(x) ⇒ Object
30 31 32 |
# File 'lib/unite/unit.rb', line 30 def value= x value end |