unitsdb 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/unitsdb/ucum.rb DELETED
@@ -1,198 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/model"
4
-
5
- module Unitsdb
6
- # <base-unit Code="s" CODE="S" dim="T">
7
- # <name>second</name>
8
- # <printSymbol>s</printSymbol>
9
- # <property>time</property>
10
- # </base-unit>
11
- class UcumBaseUnit < Lutaml::Model::Serializable
12
- attribute :code_sensitive, :string
13
- attribute :code, :string
14
- attribute :dimension, :string
15
- attribute :name, :string
16
- attribute :print_symbol, :string, raw: true
17
- attribute :property, :string
18
-
19
- xml do
20
- root "base-unit"
21
- map_attribute "Code", to: :code_sensitive
22
- map_attribute "CODE", to: :code
23
- map_attribute "dim", to: :dimension
24
- map_element "name", to: :name
25
- map_element "printSymbol", to: :print_symbol
26
- map_element "property", to: :property
27
- end
28
-
29
- def identifier
30
- "ucum:base-unit:code:#{code_sensitive}"
31
- end
32
- end
33
-
34
- # <prefix Code="Y" CODE="YA">
35
- # <name>yotta</name>
36
- # <printSymbol>Y</printSymbol>
37
- # <value value="1e24">1 &#215; 10<sup>24</sup>
38
- # </value>
39
- # </prefix>
40
-
41
- class UcumPrefixValue < Lutaml::Model::Serializable
42
- attribute :value, :string
43
- attribute :content, :string
44
-
45
- xml do
46
- root "value"
47
- map_attribute "value", to: :value
48
- map_content to: :content
49
- end
50
- end
51
-
52
- class UcumPrefix < Lutaml::Model::Serializable
53
- attribute :code_sensitive, :string
54
- attribute :code, :string
55
- attribute :name, :string
56
- attribute :print_symbol, :string, raw: true
57
- attribute :value, UcumPrefixValue
58
-
59
- xml do
60
- root "prefix"
61
- map_attribute "Code", to: :code_sensitive
62
- map_attribute "CODE", to: :code
63
- map_element "name", to: :name
64
- map_element "printSymbol", to: :print_symbol
65
- map_element "value", to: :value
66
- end
67
-
68
- def identifier
69
- "ucum:prefix:code:#{code_sensitive}"
70
- end
71
- end
72
-
73
- # <unit Code="10*" CODE="10*" isMetric="no" class="dimless">
74
- # <name>the number ten for arbitrary powers</name>
75
- # <printSymbol>10</printSymbol>
76
- # <property>number</property>
77
- # <value Unit="1" UNIT="1" value="10">10</value>
78
- # </unit>
79
-
80
- # <unit Code="gon" CODE="GON" isMetric="no" class="iso1000">
81
- # <name>gon</name>
82
- # <name>grade</name>
83
- # <printSymbol>
84
- # <sup>g</sup>
85
- # </printSymbol>
86
- # <property>plane angle</property>
87
- # <value Unit="deg" UNIT="DEG" value="0.9">0.9</value>
88
- # </unit>
89
-
90
- # <unit Code="[D'ag'U]" CODE="[D'AG'U]" isMetric="no" isArbitrary="yes"
91
- # class="chemical">
92
- # <name>D-antigen unit</name>
93
- # <printSymbol/>
94
- # <property>procedure defined amount of a poliomyelitis d-antigen substance</property>
95
- # <value Unit="1" UNIT="1" value="1">1</value>
96
- # </unit>
97
-
98
- # <unit Code="Cel" CODE="CEL" isMetric="yes" isSpecial="yes" class="si">
99
- # <name>degree Celsius</name>
100
- # <printSymbol>&#176;C</printSymbol>
101
- # <property>temperature</property>
102
- # <value Unit="cel(1 K)" UNIT="CEL(1 K)">
103
- # <function name="Cel" value="1" Unit="K"/>
104
- # </value>
105
- # </unit>
106
-
107
- class UcumUnitValueFunction < Lutaml::Model::Serializable
108
- attribute :name, :string
109
- attribute :value, :string
110
- attribute :unit_sensitive, :string
111
-
112
- xml do
113
- root "function"
114
- map_attribute "name", to: :name
115
- map_attribute "value", to: :value
116
- map_attribute "Unit", to: :unit_sensitive
117
- end
118
- end
119
-
120
- class UcumUnitValue < Lutaml::Model::Serializable
121
- attribute :unit_sensitive, :string
122
- attribute :unit, :string
123
- attribute :value, :string
124
- attribute :function, UcumUnitValueFunction
125
- attribute :content, :string
126
-
127
- xml do
128
- root "value"
129
- map_attribute "Unit", to: :unit_sensitive
130
- map_attribute "UNIT", to: :unit
131
- map_attribute "value", to: :value
132
- map_element "function", to: :function
133
- map_content to: :content
134
- end
135
- end
136
-
137
- class UcumUnit < Lutaml::Model::Serializable
138
- attribute :code_sensitive, :string
139
- attribute :code, :string
140
- attribute :is_metric, :string
141
- attribute :is_arbitrary, :string
142
- attribute :is_special, :string
143
- attribute :klass, :string
144
- attribute :name, :string, collection: true
145
- attribute :print_symbol, :string, raw: true
146
- attribute :property, :string
147
- attribute :value, UcumUnitValue
148
-
149
- xml do
150
- root "unit"
151
- map_attribute "Code", to: :code_sensitive
152
- map_attribute "CODE", to: :code
153
- map_attribute "isMetric", to: :is_metric
154
- map_attribute "isArbitrary", to: :is_arbitrary
155
- map_attribute "isSpecial", to: :is_special
156
- map_attribute "class", to: :klass
157
-
158
- map_element "name", to: :name
159
- map_element "printSymbol", to: :print_symbol
160
- map_element "property", to: :property
161
- map_element "value", to: :value
162
- end
163
-
164
- def identifier
165
- # Use empty string if klass is not present
166
- k = klass || ""
167
- "ucum:unit:#{k}:code:#{code_sensitive}"
168
- end
169
- end
170
-
171
- # This is the root element of the UCUM XML "ucum-essence.xml" file.
172
- #
173
- # <root xmlns="http://unitsofmeasure.org/ucum-essence" version="2.2" revision="N/A"
174
- # revision-date="2024-06-17">
175
-
176
- class UcumFile < Lutaml::Model::Serializable
177
- attribute :revision, :string
178
- attribute :version, :string
179
- attribute :revision_date, :date
180
- attribute :prefixes, UcumPrefix, collection: true
181
- attribute :base_units, UcumBaseUnit, collection: true
182
- attribute :units, UcumUnit, collection: true
183
-
184
- xml do
185
- root "root"
186
- namespace "http://unitsofmeasure.org/ucum-essence"
187
- map_attribute "version", to: :version
188
- map_attribute "revision", to: :revision
189
- map_attribute "revision-date", to: :revision_date
190
-
191
- map_element "prefix", to: :prefixes
192
- map_element "base-unit", to: :base_units
193
- map_element "unit", to: :units
194
- end
195
-
196
- # No adapter registration needed
197
- end
198
- end