Class: Unitwise::Standard::Function
- Inherits:
-
Object
- Object
- Unitwise::Standard::Function
- Defined in:
- lib/unitwise/standard/function.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Function
constructor
A new instance of Function.
- #name ⇒ Object
- #primary ⇒ Object
- #secondary ⇒ Object
- #to_hash ⇒ Object
- #unit ⇒ Object
- #value ⇒ Object
Constructor Details
permalink #initialize(attributes) ⇒ Function
Returns a new instance of Function.
6 7 8 |
# File 'lib/unitwise/standard/function.rb', line 6 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
permalink #attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/unitwise/standard/function.rb', line 4 def attributes @attributes end |
Instance Method Details
permalink #name ⇒ Object
[View source]
10 11 12 |
# File 'lib/unitwise/standard/function.rb', line 10 def name attributes["function"]["@name"] end |
permalink #primary ⇒ Object
[View source]
22 23 24 |
# File 'lib/unitwise/standard/function.rb', line 22 def primary attributes["@Unit"].gsub(/\(.*\)/, '') end |
permalink #secondary ⇒ Object
[View source]
26 27 28 |
# File 'lib/unitwise/standard/function.rb', line 26 def secondary attributes["@UNIT"] end |
permalink #to_hash ⇒ Object
[View source]
30 31 32 |
# File 'lib/unitwise/standard/function.rb', line 30 def to_hash {:function_code => primary, :value => value, :unit_code => unit} end |
permalink #unit ⇒ Object
[View source]
18 19 20 |
# File 'lib/unitwise/standard/function.rb', line 18 def unit attributes["function"]["@Unit"] end |
permalink #value ⇒ Object
[View source]
14 15 16 |
# File 'lib/unitwise/standard/function.rb', line 14 def value Unitwise::Number.simplify(attributes["function"]["@value"]) end |