Class: Unitwise::Standard::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/unitwise/standard/function.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#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

#attributesObject

Returns the value of attribute attributes.



4
5
6
# File 'lib/unitwise/standard/function.rb', line 4

def attributes
  @attributes
end

Instance Method Details

#nameObject



10
11
12
# File 'lib/unitwise/standard/function.rb', line 10

def name
  attributes["function"]["@name"]
end

#primaryObject



22
23
24
# File 'lib/unitwise/standard/function.rb', line 22

def primary
  attributes["@Unit"].gsub(/\(.*\)/, '')
end

#secondaryObject



26
27
28
# File 'lib/unitwise/standard/function.rb', line 26

def secondary
  attributes["@UNIT"]
end

#to_hashObject



30
31
32
# File 'lib/unitwise/standard/function.rb', line 30

def to_hash
  {:function_code => primary, :value => value, :unit_code => unit}
end

#unitObject



18
19
20
# File 'lib/unitwise/standard/function.rb', line 18

def unit
  attributes["function"]["@Unit"]
end

#valueObject



14
15
16
# File 'lib/unitwise/standard/function.rb', line 14

def value
  Unitwise::Number.simplify(attributes["function"]["@value"])
end