Class: Isq::Quantity
- Inherits:
-
SduSmart::TermEntry
- Object
- SduSmart::TermEntry
- Isq::Quantity
show all
- Includes:
- YamlAdapters
- Defined in:
- lib/isq/quantity.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#definition_from_yaml, #definition_to_yaml, #designations_from_yaml, #designations_to_yaml, #note_from_yaml, #note_to_yaml, #symbols_from_yaml, #symbols_to_yaml
Instance Attribute Details
#unit_data ⇒ Object
Returns the value of attribute unit_data.
18
19
20
|
# File 'lib/isq/quantity.rb', line 18
def unit_data
@unit_data
end
|
Instance Method Details
#definition=(value) ⇒ Object
20
21
22
23
|
# File 'lib/isq/quantity.rb', line 20
def definition=(value)
value_set_for(:definition)
@definition = value
end
|
#note=(value) ⇒ Object
25
26
27
28
|
# File 'lib/isq/quantity.rb', line 25
def note=(value)
value_set_for(:note)
@note = value
end
|
#units_from_yaml(model, value) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/isq/quantity.rb', line 96
def units_from_yaml(model, value)
unless value.is_a?(Array)
model.has_unit = []
model.unit_data = {}
return []
end
data = {}
refs = value.map do |u|
sym = Array(u["symbol"]).first
ref = if sym
"isoiec80000:unit-#{sym}"
else
name = u["en"]&.downcase&.gsub(/\s+/, "-")
"isoiec80000:unit-#{name}" if name
end
data[ref] = { name: u["en"], symbols: Array(u["symbol"]) } if ref
ref
end.compact
model.has_unit = refs
model.unit_data = data
refs
end
|
#units_to_yaml(model, doc) ⇒ Object
121
122
123
|
# File 'lib/isq/quantity.rb', line 121
def units_to_yaml(model, doc)
end
|