Class: Unitwise::Standard::DerivedUnit
- Inherits:
-
Base
- Object
- Base
- Unitwise::Standard::DerivedUnit
show all
- Defined in:
- lib/unitwise/standard/derived_unit.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
all, hash, #initialize, #names, path, #primary_code, read, #secondary_code, #symbol, write
Methods included from Extras
#hash_to_markup
Class Method Details
.local_key ⇒ Object
8
9
10
|
# File 'lib/unitwise/standard/derived_unit.rb', line 8
def self.local_key
"derived_unit"
end
|
.remote_key ⇒ Object
4
5
6
|
# File 'lib/unitwise/standard/derived_unit.rb', line 4
def self.remote_key
"unit"
end
|
Instance Method Details
#arbitrary? ⇒ Boolean
36
37
38
|
# File 'lib/unitwise/standard/derived_unit.rb', line 36
def arbitrary?
attributes["@isArbitrary"] == 'yes'
end
|
#classification ⇒ Object
24
25
26
|
# File 'lib/unitwise/standard/derived_unit.rb', line 24
def classification
attributes["@class"]
end
|
#function ⇒ Object
20
21
22
|
# File 'lib/unitwise/standard/derived_unit.rb', line 20
def function
Function.new(attributes["value"]) if special?
end
|
#metric? ⇒ Boolean
28
29
30
|
# File 'lib/unitwise/standard/derived_unit.rb', line 28
def metric?
attributes["@isMetric"] == 'yes'
end
|
#property ⇒ Object
12
13
14
|
# File 'lib/unitwise/standard/derived_unit.rb', line 12
def property
attributes["property"].to_s
end
|
#scale ⇒ Object
16
17
18
|
# File 'lib/unitwise/standard/derived_unit.rb', line 16
def scale
Scale.new(attributes["value"]) unless special?
end
|
#special? ⇒ Boolean
32
33
34
|
# File 'lib/unitwise/standard/derived_unit.rb', line 32
def special?
attributes["@isSpecial"] == 'yes'
end
|
#to_hash ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/unitwise/standard/derived_unit.rb', line 40
def to_hash
hash = super()
hash[:scale] = (special? ? function.to_hash : scale.to_hash)
hash.merge({:classification => classification,
:property => property, :metric => metric?,
:special => special?, :arbitrary => arbitrary?})
end
|