Class: Unitwise::Standard::Scale

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nori) ⇒ Scale

Returns a new instance of Scale.



5
6
7
# File 'lib/unitwise/standard/scale.rb', line 5

def initialize(nori)
  @nori = nori
end

Instance Attribute Details

#noriObject

Returns the value of attribute nori.



3
4
5
# File 'lib/unitwise/standard/scale.rb', line 3

def nori
  @nori
end

Instance Method Details

#primary_unit_codeObject



13
14
15
# File 'lib/unitwise/standard/scale.rb', line 13

def primary_unit_code
  nori.attributes["Unit"]
end

#secondary_unit_codeObject



17
18
19
# File 'lib/unitwise/standard/scale.rb', line 17

def secondary_unit_code
  nori.attributes["UNIT"]
end

#to_hashObject



21
22
23
# File 'lib/unitwise/standard/scale.rb', line 21

def to_hash
  {:value => value, :unit_code => primary_unit_code}
end

#valueObject



9
10
11
# File 'lib/unitwise/standard/scale.rb', line 9

def value
  Unitwise::Number.coefficify(nori.attributes.fetch('value'))
end