unitsdb 0.1.1 → 2.0.1
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.
- checksums.yaml +4 -4
- data/.github/workflows/dependent-repos.json +5 -0
- data/.github/workflows/depenedent-gems.yml +16 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -1
- data/.rubocop_todo.yml +168 -15
- data/Gemfile +3 -2
- data/README.adoc +803 -1
- data/exe/unitsdb +7 -0
- data/lib/unitsdb/cli.rb +88 -0
- data/lib/unitsdb/commands/_modify.rb +22 -0
- data/lib/unitsdb/commands/base.rb +26 -0
- data/lib/unitsdb/commands/check_si.rb +124 -0
- data/lib/unitsdb/commands/get.rb +133 -0
- data/lib/unitsdb/commands/normalize.rb +81 -0
- data/lib/unitsdb/commands/release.rb +73 -0
- data/lib/unitsdb/commands/search.rb +219 -0
- data/lib/unitsdb/commands/si_formatter.rb +485 -0
- data/lib/unitsdb/commands/si_matcher.rb +470 -0
- data/lib/unitsdb/commands/si_ttl_parser.rb +100 -0
- data/lib/unitsdb/commands/si_updater.rb +212 -0
- data/lib/unitsdb/commands/ucum/check.rb +126 -0
- data/lib/unitsdb/commands/ucum/formatter.rb +141 -0
- data/lib/unitsdb/commands/ucum/matcher.rb +301 -0
- data/lib/unitsdb/commands/ucum/update.rb +84 -0
- data/lib/unitsdb/commands/ucum/updater.rb +98 -0
- data/lib/unitsdb/commands/ucum/xml_parser.rb +34 -0
- data/lib/unitsdb/commands/ucum.rb +43 -0
- data/lib/unitsdb/commands/validate/identifiers.rb +42 -0
- data/lib/unitsdb/commands/validate/references.rb +318 -0
- data/lib/unitsdb/commands/validate/si_references.rb +109 -0
- data/lib/unitsdb/commands/validate.rb +40 -0
- data/lib/unitsdb/config.rb +19 -0
- data/lib/unitsdb/database.rb +662 -0
- data/lib/unitsdb/dimension.rb +19 -25
- data/lib/unitsdb/dimension_details.rb +20 -0
- data/lib/unitsdb/dimension_reference.rb +8 -0
- data/lib/unitsdb/dimensions.rb +4 -6
- data/lib/unitsdb/errors.rb +13 -0
- data/lib/unitsdb/external_reference.rb +14 -0
- data/lib/unitsdb/identifier.rb +8 -0
- data/lib/unitsdb/localized_string.rb +17 -0
- data/lib/unitsdb/prefix.rb +11 -12
- data/lib/unitsdb/prefix_reference.rb +10 -0
- data/lib/unitsdb/prefixes.rb +4 -6
- data/lib/unitsdb/quantities.rb +4 -27
- data/lib/unitsdb/quantity.rb +12 -24
- data/lib/unitsdb/quantity_reference.rb +4 -7
- data/lib/unitsdb/root_unit_reference.rb +14 -0
- data/lib/unitsdb/scale.rb +17 -0
- data/lib/unitsdb/scale_properties.rb +12 -0
- data/lib/unitsdb/scale_reference.rb +10 -0
- data/lib/unitsdb/scales.rb +12 -0
- data/lib/unitsdb/si_derived_base.rb +13 -14
- data/lib/unitsdb/symbol_presentations.rb +14 -0
- data/lib/unitsdb/ucum.rb +198 -0
- data/lib/unitsdb/unit.rb +20 -26
- data/lib/unitsdb/unit_reference.rb +5 -8
- data/lib/unitsdb/unit_system.rb +8 -10
- data/lib/unitsdb/unit_system_reference.rb +10 -0
- data/lib/unitsdb/unit_systems.rb +4 -16
- data/lib/unitsdb/units.rb +4 -6
- data/lib/unitsdb/utils.rb +84 -0
- data/lib/unitsdb/version.rb +1 -1
- data/lib/unitsdb.rb +13 -10
- data/unitsdb.gemspec +6 -3
- metadata +120 -12
- data/lib/unitsdb/dimension_quantity.rb +0 -28
- data/lib/unitsdb/dimension_symbol.rb +0 -22
- data/lib/unitsdb/prefix_symbol.rb +0 -12
- data/lib/unitsdb/root_unit.rb +0 -17
- data/lib/unitsdb/root_units.rb +0 -20
- data/lib/unitsdb/symbol.rb +0 -17
- data/lib/unitsdb/unit_symbol.rb +0 -15
- data/lib/unitsdb/unitsdb.rb +0 -6
data/lib/unitsdb/dimension.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
3
|
+
require_relative "identifier"
|
4
|
+
require_relative "dimension_details"
|
5
|
+
require_relative "quantity"
|
6
|
+
require_relative "localized_string"
|
4
7
|
# NISTd1:
|
5
8
|
# length:
|
6
|
-
#
|
9
|
+
# power: 1
|
7
10
|
# symbol: L
|
8
11
|
# dim_symbols:
|
9
12
|
# - id: "dim_L"
|
@@ -23,33 +26,24 @@ require_relative "dimension_quantity"
|
|
23
26
|
# - latex: "\\ensuremath{\\mathsf{\\phi}}"
|
24
27
|
# - mathml: "<mi mathvariant='sans-serif'>φ</mi>"
|
25
28
|
# - unicode: "\U0001D785"
|
26
|
-
# -
|
29
|
+
# - power: 1
|
27
30
|
# - symbol: phi
|
28
31
|
|
29
32
|
module Unitsdb
|
30
33
|
class Dimension < Lutaml::Model::Serializable
|
31
|
-
|
32
|
-
attribute :dimensionless, :boolean
|
33
|
-
attribute :length, DimensionQuantity
|
34
|
-
attribute :mass, DimensionQuantity
|
35
|
-
attribute :time, DimensionQuantity
|
36
|
-
attribute :electric_current, DimensionQuantity
|
37
|
-
attribute :thermodynamic_temperature, DimensionQuantity
|
38
|
-
attribute :amount_of_substance, DimensionQuantity
|
39
|
-
attribute :luminous_intensity, DimensionQuantity
|
40
|
-
attribute :plane_angle, DimensionQuantity
|
34
|
+
# model Config.model_for(:dimension)
|
41
35
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
36
|
+
attribute :identifiers, Identifier, collection: true
|
37
|
+
attribute :dimensionless, :boolean
|
38
|
+
attribute :length, DimensionDetails
|
39
|
+
attribute :mass, DimensionDetails
|
40
|
+
attribute :time, DimensionDetails
|
41
|
+
attribute :electric_current, DimensionDetails
|
42
|
+
attribute :thermodynamic_temperature, DimensionDetails
|
43
|
+
attribute :amount_of_substance, DimensionDetails
|
44
|
+
attribute :luminous_intensity, DimensionDetails
|
45
|
+
attribute :plane_angle, DimensionDetails
|
46
|
+
attribute :short, :string
|
47
|
+
attribute :names, LocalizedString, collection: true
|
54
48
|
end
|
55
49
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# power: 1
|
4
|
+
# symbol: M
|
5
|
+
# symbols:
|
6
|
+
# - ascii: M
|
7
|
+
# html: "𝖬"
|
8
|
+
# id: dim_M
|
9
|
+
# latex: "\\ensuremath{\\mathsf{M}}"
|
10
|
+
# mathml: "<mi mathvariant='sans-serif'>M</mi>"
|
11
|
+
# unicode: "\U0001D5AC"
|
12
|
+
|
13
|
+
require_relative "symbol_presentations"
|
14
|
+
module Unitsdb
|
15
|
+
class DimensionDetails < Lutaml::Model::Serializable
|
16
|
+
attribute :power, :integer
|
17
|
+
attribute :symbol, :string
|
18
|
+
attribute :symbols, SymbolPresentations, collection: true
|
19
|
+
end
|
20
|
+
end
|
data/lib/unitsdb/dimensions.rb
CHANGED
@@ -4,12 +4,10 @@ require_relative "dimension"
|
|
4
4
|
|
5
5
|
module Unitsdb
|
6
6
|
class Dimensions < Lutaml::Model::Serializable
|
7
|
-
|
7
|
+
# model Config.model_for(:dimensions)
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
end
|
9
|
+
attribute :schema_version, :string
|
10
|
+
attribute :version, :string
|
11
|
+
attribute :dimensions, Dimension, collection: true
|
14
12
|
end
|
15
13
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unitsdb
|
4
|
+
module Errors
|
5
|
+
class DatabaseError < StandardError; end
|
6
|
+
class DatabaseNotFoundError < DatabaseError; end
|
7
|
+
class DatabaseFileNotFoundError < DatabaseError; end
|
8
|
+
class DatabaseFileInvalidError < DatabaseError; end
|
9
|
+
class DatabaseLoadError < DatabaseError; end
|
10
|
+
class VersionMismatchError < DatabaseError; end
|
11
|
+
class UnsupportedVersionError < DatabaseError; end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# references:
|
4
|
+
# - uri: http://si-digital-framework.org/quantities/LENG
|
5
|
+
# type: normative
|
6
|
+
# authority: si-digital-framework
|
7
|
+
|
8
|
+
module Unitsdb
|
9
|
+
class ExternalReference < Identifier
|
10
|
+
attribute :uri, :string
|
11
|
+
attribute :type, :string, values: %w[normative informative]
|
12
|
+
attribute :authority, :string
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unitsdb
|
4
|
+
# Represents a localized string with a language tag
|
5
|
+
class LocalizedString < Lutaml::Model::Serializable
|
6
|
+
attribute :value, :string
|
7
|
+
attribute :lang, :string
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
"#{value} (#{lang})"
|
11
|
+
end
|
12
|
+
|
13
|
+
def downcase
|
14
|
+
value&.downcase
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/unitsdb/prefix.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
3
|
+
require_relative "identifier"
|
4
|
+
require_relative "symbol_presentations"
|
5
|
+
require_relative "external_reference"
|
6
|
+
require_relative "localized_string"
|
4
7
|
# ---
|
5
8
|
# NISTp10_30:
|
6
9
|
# name: quetta
|
@@ -14,18 +17,14 @@ require_relative "prefix_symbol"
|
|
14
17
|
|
15
18
|
module Unitsdb
|
16
19
|
class Prefix < Lutaml::Model::Serializable
|
17
|
-
|
18
|
-
|
19
|
-
attribute :
|
20
|
+
# model Config.model_for(:prefix)
|
21
|
+
|
22
|
+
attribute :identifiers, Identifier, collection: true
|
23
|
+
attribute :names, LocalizedString, collection: true
|
24
|
+
attribute :short, :string
|
25
|
+
attribute :symbols, SymbolPresentations, collection: true
|
20
26
|
attribute :base, :integer
|
21
27
|
attribute :power, :integer
|
22
|
-
|
23
|
-
key_value do
|
24
|
-
map :id, to: :id
|
25
|
-
map :name, to: :name
|
26
|
-
map :symbol, to: :symbol
|
27
|
-
map :base, to: :base
|
28
|
-
map :power, to: :power
|
29
|
-
end
|
28
|
+
attribute :references, ExternalReference, collection: true
|
30
29
|
end
|
31
30
|
end
|
data/lib/unitsdb/prefixes.rb
CHANGED
@@ -14,12 +14,10 @@ require_relative "prefix"
|
|
14
14
|
|
15
15
|
module Unitsdb
|
16
16
|
class Prefixes < Lutaml::Model::Serializable
|
17
|
-
|
17
|
+
# model Config.model_for(:prefixes)
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
23
|
-
end
|
19
|
+
attribute :schema_version, :string
|
20
|
+
attribute :version, :string
|
21
|
+
attribute :prefixes, Prefix, collection: true
|
24
22
|
end
|
25
23
|
end
|
data/lib/unitsdb/quantities.rb
CHANGED
@@ -1,35 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# # Quantities
|
4
|
-
# NISTq156:
|
5
|
-
# dimension_url: "#NISTd68"
|
6
|
-
# quantity_type: derived
|
7
|
-
# quantity_name:
|
8
|
-
# - linear expansion coefficient
|
9
|
-
# unit_reference:
|
10
|
-
# - name: kelvin to the power minus one
|
11
|
-
# url: "#NISTu5e-1/1"
|
12
|
-
|
13
|
-
# NISTq155:
|
14
|
-
# dimension_url: "#NISTd57"
|
15
|
-
# quantity_type: derived
|
16
|
-
# quantity_name:
|
17
|
-
# - area moment of inertia
|
18
|
-
# - second moment of area
|
19
|
-
# unit_reference:
|
20
|
-
# - name: inch to the fourth power
|
21
|
-
# url: "#NISTu208"
|
22
|
-
|
23
3
|
require_relative "quantity"
|
24
4
|
|
25
5
|
module Unitsdb
|
26
6
|
class Quantities < Lutaml::Model::Serializable
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
id: :key
|
32
|
-
}
|
33
|
-
end
|
7
|
+
# model Config.model_for(:quantities)
|
8
|
+
attribute :schema_version, :string
|
9
|
+
attribute :version, :string
|
10
|
+
attribute :quantities, Quantity, collection: true
|
34
11
|
end
|
35
12
|
end
|
data/lib/unitsdb/quantity.rb
CHANGED
@@ -1,33 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# NISTq156:
|
5
|
-
# dimension_url: "#NISTd68"
|
6
|
-
# quantity_type: derived
|
7
|
-
# quantity_name:
|
8
|
-
# - linear expansion coefficient
|
9
|
-
# unit_reference:
|
10
|
-
# - name: kelvin to the power minus one
|
11
|
-
# url: "#NISTu5e-1/1"
|
12
|
-
|
13
|
-
# NISTq155:
|
14
|
-
# dimension_url: "#NISTd57"
|
15
|
-
# quantity_type: derived
|
16
|
-
# quantity_name:
|
17
|
-
# - area moment of inertia
|
18
|
-
# - second moment of area
|
19
|
-
# unit_reference:
|
20
|
-
# - name: inch to the fourth power
|
21
|
-
# url: "#NISTu208"
|
22
|
-
|
3
|
+
require_relative "identifier"
|
23
4
|
require_relative "unit_reference"
|
5
|
+
require_relative "dimension_reference"
|
6
|
+
require_relative "external_reference"
|
7
|
+
require_relative "localized_string"
|
24
8
|
|
25
9
|
module Unitsdb
|
26
10
|
class Quantity < Lutaml::Model::Serializable
|
27
|
-
|
28
|
-
|
11
|
+
# model Config.model_for(:quantity)
|
12
|
+
|
13
|
+
attribute :identifiers, Identifier, collection: true
|
29
14
|
attribute :quantity_type, :string
|
30
|
-
attribute :
|
31
|
-
attribute :
|
15
|
+
attribute :names, LocalizedString, collection: true
|
16
|
+
attribute :short, :string
|
17
|
+
attribute :unit_references, UnitReference, collection: true
|
18
|
+
attribute :dimension_reference, DimensionReference
|
19
|
+
attribute :references, ExternalReference, collection: true
|
32
20
|
end
|
33
21
|
end
|
@@ -1,13 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Unitsdb
|
4
|
-
class QuantityReference <
|
5
|
-
|
6
|
-
attribute :url, :string
|
4
|
+
class QuantityReference < Identifier
|
5
|
+
# model Config.model_for(:quantity_reference)
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
map :url, to: :url
|
11
|
-
end
|
7
|
+
attribute :id, :string
|
8
|
+
attribute :type, :string
|
12
9
|
end
|
13
10
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "unit_reference"
|
4
|
+
require_relative "prefix_reference"
|
5
|
+
|
6
|
+
module Unitsdb
|
7
|
+
class RootUnitReference < Lutaml::Model::Serializable
|
8
|
+
# model Config.model_for(:root_unit)
|
9
|
+
|
10
|
+
attribute :power, :integer
|
11
|
+
attribute :unit_reference, UnitReference
|
12
|
+
attribute :prefix_reference, PrefixReference
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "identifier"
|
4
|
+
require_relative "localized_string"
|
5
|
+
require_relative "scale_properties"
|
6
|
+
|
7
|
+
module Unitsdb
|
8
|
+
class Scale < Lutaml::Model::Serializable
|
9
|
+
# model Config.model_for(:quantity)
|
10
|
+
|
11
|
+
attribute :identifiers, Identifier, collection: true
|
12
|
+
attribute :names, LocalizedString, collection: true
|
13
|
+
attribute :description, LocalizedString, collection: true
|
14
|
+
attribute :short, :string
|
15
|
+
attribute :properties, ScaleProperties
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unitsdb
|
4
|
+
class ScaleProperties < Lutaml::Model::Serializable
|
5
|
+
# model Config.model_for(:quantity)
|
6
|
+
attribute :continuous, :boolean
|
7
|
+
attribute :ordered, :boolean
|
8
|
+
attribute :logarithmic, :boolean
|
9
|
+
attribute :interval, :boolean
|
10
|
+
attribute :ratio, :boolean
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "scale"
|
4
|
+
|
5
|
+
module Unitsdb
|
6
|
+
class Scales < Lutaml::Model::Serializable
|
7
|
+
# model Config.model_for(:Scale)
|
8
|
+
attribute :schema_version, :string
|
9
|
+
attribute :version, :string
|
10
|
+
attribute :scales, Scale, collection: true
|
11
|
+
end
|
12
|
+
end
|
@@ -1,20 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# prefix:
|
5
|
-
# power: 1
|
6
|
-
# - id: NISTu1
|
7
|
-
# prefix:
|
8
|
-
# power: -1
|
3
|
+
require_relative "root_unit_reference"
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
# si_derived_bases:
|
6
|
+
# - power: 2
|
7
|
+
# unit_reference:
|
8
|
+
# id: NISTu1
|
9
|
+
# type: nist
|
10
|
+
# - power: -2
|
11
|
+
# unit_reference:
|
12
|
+
# id: NISTu1
|
13
|
+
# type: nist
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
map :power, to: :power
|
15
|
+
module Unitsdb
|
16
|
+
class SiDerivedBase < RootUnitReference
|
17
|
+
# model Config.model_for(:si_derived_base)
|
19
18
|
end
|
20
19
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unitsdb
|
4
|
+
class SymbolPresentations < Lutaml::Model::Serializable
|
5
|
+
# model Config.model_for(:symbol_presentations)
|
6
|
+
|
7
|
+
attribute :id, :string
|
8
|
+
attribute :ascii, :string
|
9
|
+
attribute :html, :string
|
10
|
+
attribute :latex, :string
|
11
|
+
attribute :mathml, :string
|
12
|
+
attribute :unicode, :string
|
13
|
+
end
|
14
|
+
end
|
data/lib/unitsdb/ucum.rb
ADDED
@@ -0,0 +1,198 @@
|
|
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 × 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>°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
|