unitsml 0.3.0 → 0.4.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/Gemfile +1 -0
- data/lib/unitsml/dimension.rb +47 -38
- data/lib/unitsml/extender.rb +24 -10
- data/lib/unitsml/formula.rb +79 -55
- data/lib/unitsml/model/dimension.rb +42 -0
- data/lib/unitsml/model/dimension_quantities/amount_of_substance.rb +10 -0
- data/lib/unitsml/model/dimension_quantities/electric_current.rb +10 -0
- data/lib/unitsml/model/dimension_quantities/length.rb +10 -0
- data/lib/unitsml/model/dimension_quantities/luminous_intensity.rb +10 -0
- data/lib/unitsml/model/dimension_quantities/mass.rb +10 -0
- data/lib/unitsml/model/dimension_quantities/plane_angle.rb +10 -0
- data/lib/unitsml/model/dimension_quantities/quantity.rb +17 -0
- data/lib/unitsml/model/dimension_quantities/thermodynamic_temperature.rb +10 -0
- data/lib/unitsml/model/dimension_quantities/time.rb +10 -0
- data/lib/unitsml/model/prefix.rb +28 -0
- data/lib/unitsml/model/prefixes/name.rb +19 -0
- data/lib/unitsml/model/prefixes/symbol.rb +19 -0
- data/lib/unitsml/model/quantities/name.rb +19 -0
- data/lib/unitsml/model/quantity.rb +24 -0
- data/lib/unitsml/model/unit.rb +31 -0
- data/lib/unitsml/model/units/enumerated_root_unit.rb +19 -0
- data/lib/unitsml/model/units/name.rb +19 -0
- data/lib/unitsml/model/units/root_units.rb +17 -0
- data/lib/unitsml/model/units/symbol.rb +26 -0
- data/lib/unitsml/model/units/system.rb +21 -0
- data/lib/unitsml/parse.rb +5 -7
- data/lib/unitsml/parser.rb +3 -3
- data/lib/unitsml/prefix.rb +21 -21
- data/lib/unitsml/sqrt.rb +10 -10
- data/lib/unitsml/unit.rb +35 -35
- data/lib/unitsml/unitsdb/dimension.rb +88 -0
- data/lib/unitsml/unitsdb/dimension_quantity.rb +15 -0
- data/lib/unitsml/unitsdb/dimensions.rb +38 -0
- data/lib/unitsml/unitsdb/prefixes.rb +22 -0
- data/lib/unitsml/unitsdb/quantities.rb +13 -0
- data/lib/unitsml/unitsdb/units.rb +44 -0
- data/lib/unitsml/unitsdb.rb +13 -71
- data/lib/unitsml/utility.rb +101 -111
- data/lib/unitsml/version.rb +1 -1
- data/lib/unitsml.rb +26 -6
- data/unitsml.gemspec +2 -1
- metadata +46 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6632e70a14a2c9662b85b1112a0569486677426e017cb088ebdc8f1e731e05c
|
4
|
+
data.tar.gz: 4fa710e853070a32fac7270f42fe69943fec949640aca6e42808416a95d5a28e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3624ad9bc0876043b78eff8f42d6894c0b4acc3d6a1938dd60e1f9ed7506f781c6fe96257c9cbd3e85a31a793833b8d021bb56300140faecd21eb47facd5eddc
|
7
|
+
data.tar.gz: 1443c411718074a7fcff0c7362158233530777e31b09cf3a1e58379579ed3fa0a94ecfa08aca519cc2d59193d22834e9f224c0be6966307095ab140237d46b5c
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: dependent-gems-test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
tags: [ v* ]
|
7
|
+
pull_request:
|
8
|
+
workflow_dispatch:
|
9
|
+
repository_dispatch:
|
10
|
+
types: [ release-passed ]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
rake:
|
14
|
+
uses: metanorma/ci/.github/workflows/dependent-rake.yml@main
|
15
|
+
with:
|
16
|
+
command: bundle exec rspec
|
data/Gemfile
CHANGED
data/lib/unitsml/dimension.rb
CHANGED
@@ -15,53 +15,46 @@ module Unitsml
|
|
15
15
|
power_numerator == object&.power_numerator
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
Unitsdb.
|
18
|
+
def dim_instance
|
19
|
+
@dim ||= Unitsdb.dimensions.find_parsables_by_id(dimension_name)
|
20
20
|
end
|
21
21
|
|
22
22
|
def dim_symbols
|
23
|
-
|
23
|
+
dim_instance.send(@dim.processed_keys.last).dim_symbols.first
|
24
24
|
end
|
25
25
|
|
26
|
-
def to_mathml
|
27
|
-
value
|
28
|
-
value =
|
26
|
+
def to_mathml(_)
|
27
|
+
# MathML key's value in unitsdb/dimensions.yaml file includes mi tags only.
|
28
|
+
value = ::Mml::Mi.from_xml(dim_symbols.mathml)
|
29
|
+
method_name = power_numerator ? :msup : :mi
|
29
30
|
if power_numerator
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
value = ::Mml::Msup.new(
|
32
|
+
mrow_value: [
|
33
|
+
::Mml::Mrow.new(mi_value: [value]),
|
34
|
+
::Mml::Mrow.new(
|
35
|
+
mn_value: [::Mml::Mn.new(value: power_numerator)],
|
36
|
+
),
|
37
|
+
]
|
36
38
|
)
|
37
|
-
value = msup
|
38
39
|
end
|
39
|
-
value
|
40
|
+
{ method_name: method_name, value: value }
|
40
41
|
end
|
41
42
|
|
42
|
-
def to_latex
|
43
|
-
|
44
|
-
if power_numerator
|
45
|
-
value = "#{value}^#{power_numerator}"
|
46
|
-
end
|
47
|
-
value
|
43
|
+
def to_latex(_)
|
44
|
+
power_numerator_generic_code(:latex)
|
48
45
|
end
|
49
46
|
|
50
|
-
def to_asciimath
|
51
|
-
|
52
|
-
value = "#{value}^#{power_numerator}" if power_numerator
|
53
|
-
value
|
47
|
+
def to_asciimath(_)
|
48
|
+
power_numerator_generic_code(:ascii)
|
54
49
|
end
|
55
50
|
|
56
|
-
def
|
57
|
-
|
58
|
-
value = "#{value}<sup>#{power_numerator}</sup>" if power_numerator
|
59
|
-
value
|
51
|
+
def to_unicode(_)
|
52
|
+
power_numerator_generic_code(:unicode)
|
60
53
|
end
|
61
54
|
|
62
|
-
def
|
63
|
-
value = dim_symbols
|
64
|
-
value = "#{value}
|
55
|
+
def to_html(_)
|
56
|
+
value = dim_symbols.html
|
57
|
+
value = "#{value}<sup>#{power_numerator}</sup>" if power_numerator
|
65
58
|
value
|
66
59
|
end
|
67
60
|
|
@@ -69,17 +62,33 @@ module Unitsml
|
|
69
62
|
"#{dimension_name.split('_').last}#{power_numerator}"
|
70
63
|
end
|
71
64
|
|
72
|
-
def to_xml
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
65
|
+
def to_xml(_)
|
66
|
+
attributes = {
|
67
|
+
symbol: dim_instance.processed_symbol,
|
68
|
+
power_numerator: power_numerator || 1,
|
69
|
+
}
|
70
|
+
Model::DimensionQuantities.const_get(modelize(element_name)).new(attributes)
|
71
|
+
end
|
72
|
+
|
73
|
+
def xml_instances_hash(options)
|
74
|
+
{ element_name => to_xml(options) }
|
79
75
|
end
|
80
76
|
|
81
77
|
def modelize(value)
|
82
78
|
value&.split("_")&.map(&:capitalize)&.join
|
83
79
|
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def power_numerator_generic_code(method_name)
|
84
|
+
value = dim_symbols.public_send(method_name)
|
85
|
+
return value unless power_numerator
|
86
|
+
|
87
|
+
"#{value}^#{power_numerator}"
|
88
|
+
end
|
89
|
+
|
90
|
+
def element_name
|
91
|
+
dim_instance.processed_keys.first
|
92
|
+
end
|
84
93
|
end
|
85
94
|
end
|
data/lib/unitsml/extender.rb
CHANGED
@@ -13,24 +13,38 @@ module Unitsml
|
|
13
13
|
symbol == object&.symbol
|
14
14
|
end
|
15
15
|
|
16
|
-
def to_mathml
|
17
|
-
|
16
|
+
def to_mathml(options)
|
17
|
+
multiplier = case options[:multiplier]
|
18
|
+
when :space
|
19
|
+
rspace = "thickmathspace"
|
20
|
+
"⁢"
|
21
|
+
when :nospace
|
22
|
+
"⁢"
|
23
|
+
else
|
24
|
+
extender = options[:multiplier] || "⋅"
|
25
|
+
Utility.string_to_html_entity(extender)
|
26
|
+
end
|
27
|
+
{
|
28
|
+
method_name: :mo,
|
29
|
+
value: ::Mml::Mo.new(value: multiplier, rspace: rspace),
|
30
|
+
}
|
18
31
|
end
|
19
32
|
|
20
|
-
def to_latex
|
21
|
-
"/"
|
33
|
+
def to_latex(options)
|
34
|
+
options[:multiplier] || "/"
|
22
35
|
end
|
23
36
|
|
24
|
-
def to_asciimath
|
25
|
-
symbol
|
37
|
+
def to_asciimath(options)
|
38
|
+
options[:multiplier] || symbol
|
26
39
|
end
|
27
40
|
|
28
|
-
def to_html
|
29
|
-
"⋅"
|
41
|
+
def to_html(options)
|
42
|
+
options[:multiplier] || "⋅"
|
30
43
|
end
|
31
44
|
|
32
|
-
def to_unicode
|
33
|
-
|
45
|
+
def to_unicode(options)
|
46
|
+
options[:multiplier] ||
|
47
|
+
symbol == "*" ? "·" : symbol
|
34
48
|
end
|
35
49
|
end
|
36
50
|
end
|
data/lib/unitsml/formula.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "mml"
|
4
|
+
require "htmlentities"
|
5
|
+
require "unitsml/utility"
|
4
6
|
module Unitsml
|
5
7
|
class Formula
|
6
8
|
attr_accessor :value, :explicit_value, :root
|
@@ -24,61 +26,68 @@ module Unitsml
|
|
24
26
|
root == object.root
|
25
27
|
end
|
26
28
|
|
27
|
-
def to_mathml
|
29
|
+
def to_mathml(options = {})
|
28
30
|
if root
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
)
|
36
|
-
|
31
|
+
update_options(options)
|
32
|
+
nullify_mml_models if plurimath_available?
|
33
|
+
math = ::Mml::MathWithNamespace.new(display: "block")
|
34
|
+
math.ordered = true
|
35
|
+
math.element_order ||= []
|
36
|
+
value.each do |instance|
|
37
|
+
processed_instance = instance.to_mathml(options)
|
38
|
+
case processed_instance
|
39
|
+
when Array
|
40
|
+
processed_instance.each { |hash| add_math_element(math, hash) }
|
41
|
+
when Hash
|
42
|
+
add_math_element(math, processed_instance)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
reset_mml_models if plurimath_available?
|
46
|
+
math.to_xml.gsub(/&(.*?)(?=<\/)/, '&\1')
|
37
47
|
else
|
38
|
-
value.map(
|
48
|
+
value.map { |obj| obj.to_mathml(options) }
|
39
49
|
end
|
40
50
|
end
|
41
51
|
|
42
|
-
def to_latex
|
43
|
-
value.map(
|
52
|
+
def to_latex(options = {})
|
53
|
+
value.map { |obj| obj.to_latex(update_options(options)) }.join
|
44
54
|
end
|
45
55
|
|
46
|
-
def to_asciimath
|
47
|
-
value.map(
|
56
|
+
def to_asciimath(options = {})
|
57
|
+
value.map { |obj| obj.to_asciimath(update_options(options)) }.join
|
48
58
|
end
|
49
59
|
|
50
|
-
def to_html
|
51
|
-
value.map(
|
60
|
+
def to_html(options = {})
|
61
|
+
value.map { |obj| obj.to_html(update_options(options)) }.join
|
52
62
|
end
|
53
63
|
|
54
|
-
def to_unicode
|
55
|
-
value.map(
|
64
|
+
def to_unicode(options = {})
|
65
|
+
value.map { |obj| obj.to_unicode(update_options(options)) }.join
|
56
66
|
end
|
57
67
|
|
58
|
-
def to_xml
|
59
|
-
|
60
|
-
if (dimensions_array).any?
|
61
|
-
dimensions(sort_dims(dimensions_array))
|
68
|
+
def to_xml(options = {})
|
69
|
+
update_options(options)
|
70
|
+
if (dimensions_array = extract_dimensions(value)).any?
|
71
|
+
dimensions(sort_dims(dimensions_array), options)
|
62
72
|
elsif @orig_text.match(/-$/)
|
63
|
-
prefixes
|
73
|
+
prefixes(options)
|
64
74
|
else
|
65
|
-
units
|
75
|
+
units(options)
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
69
|
-
def to_plurimath
|
79
|
+
def to_plurimath(options = {})
|
70
80
|
ensure_plurimath_defined!
|
71
|
-
|
81
|
+
options = update_options(options)
|
82
|
+
return Plurimath::Math.parse(to_asciimath(options), :asciimath) if @orig_text.match?(/-$/)
|
72
83
|
|
73
|
-
Plurimath::Math.parse(to_mathml, :mathml)
|
84
|
+
Plurimath::Math.parse(to_mathml(options), :mathml)
|
74
85
|
end
|
75
86
|
|
76
87
|
private
|
77
88
|
|
78
89
|
def extract_dimensions(formula)
|
79
|
-
|
80
|
-
|
81
|
-
formula.each do |term|
|
90
|
+
formula.each_with_object([]) do |term, dimensions|
|
82
91
|
if term.is_a?(Dimension)
|
83
92
|
dimensions << term
|
84
93
|
elsif term.is_a?(Sqrt) && term.value.is_a?(Dimension)
|
@@ -89,14 +98,10 @@ module Unitsml
|
|
89
98
|
dimensions.concat(extract_dimensions(term.value))
|
90
99
|
end
|
91
100
|
end
|
92
|
-
|
93
|
-
dimensions
|
94
101
|
end
|
95
102
|
|
96
103
|
def extract_units(formula)
|
97
|
-
|
98
|
-
|
99
|
-
formula.each do |term|
|
104
|
+
formula.each_with_object([]) do |term, units_arr|
|
100
105
|
case term
|
101
106
|
when Unit
|
102
107
|
units_arr << term.dup
|
@@ -108,20 +113,16 @@ module Unitsml
|
|
108
113
|
units_arr << term.value
|
109
114
|
end
|
110
115
|
end
|
111
|
-
|
112
|
-
units_arr
|
113
116
|
end
|
114
117
|
|
115
|
-
def units
|
118
|
+
def units(options)
|
116
119
|
all_units = extract_units(value)
|
117
120
|
norm_text = Utility.postprocess_normtext(all_units)
|
118
121
|
dims = Utility.units2dimensions(extract_units(value))
|
119
|
-
dimension, dimension_component = unique_dimensions(dims, norm_text)
|
120
122
|
[
|
121
|
-
Utility.unit(all_units, self, dims, norm_text, explicit_value&.dig(:name)),
|
122
|
-
Utility.prefixes(all_units),
|
123
|
-
|
124
|
-
dimension_component,
|
123
|
+
Utility.unit(all_units, self, dims, norm_text, explicit_value&.dig(:name), options),
|
124
|
+
Utility.prefixes(all_units, options),
|
125
|
+
*unique_dimensions(dims, norm_text),
|
125
126
|
Utility.quantity(norm_text, explicit_value&.dig(:quantity)),
|
126
127
|
].join
|
127
128
|
end
|
@@ -133,15 +134,11 @@ module Unitsml
|
|
133
134
|
].uniq
|
134
135
|
end
|
135
136
|
|
136
|
-
def dimensions(dims)
|
137
|
+
def dimensions(dims, options)
|
137
138
|
dim_id = dims.map(&:generate_id).join
|
138
|
-
attributes = {
|
139
|
-
|
140
|
-
|
141
|
-
Utility.ox_element("Dimension", attributes: attributes),
|
142
|
-
dims.map(&:to_xml),
|
143
|
-
),
|
144
|
-
)
|
139
|
+
attributes = { id: "D_#{dim_id}" }
|
140
|
+
dims.each { |dim| attributes.merge!(dim.xml_instances_hash(options)) }
|
141
|
+
Model::Dimension.new(attributes).to_xml
|
145
142
|
end
|
146
143
|
|
147
144
|
def sort_dims(values)
|
@@ -151,22 +148,49 @@ module Unitsml
|
|
151
148
|
end
|
152
149
|
end
|
153
150
|
|
154
|
-
def prefixes
|
151
|
+
def prefixes(options)
|
155
152
|
norm_text = @norm_text&.split("-")&.first
|
156
153
|
prefix_object = Unit.new("", prefix: Prefix.new(norm_text))
|
157
154
|
[
|
158
|
-
Utility.prefixes([prefix_object]),
|
155
|
+
Utility.prefixes([prefix_object], options),
|
159
156
|
Utility.dimension(norm_text),
|
160
157
|
Utility.quantity(norm_text, explicit_value&.dig(:quantity)),
|
161
158
|
].join
|
162
159
|
end
|
163
160
|
|
164
161
|
def ensure_plurimath_defined!
|
165
|
-
return if
|
162
|
+
return if plurimath_available?
|
166
163
|
|
167
164
|
require "plurimath"
|
168
165
|
rescue LoadError => e
|
169
166
|
raise Errors::PlurimathLoadError
|
170
167
|
end
|
168
|
+
|
169
|
+
def add_math_element(math_instance, child_hash)
|
170
|
+
method_name = child_hash[:method_name]
|
171
|
+
method_value = math_instance.public_send(:"#{method_name}_value")
|
172
|
+
method_value += Array(child_hash[:value])
|
173
|
+
math_instance.public_send(:"#{method_name}_value=", method_value)
|
174
|
+
math_instance.element_order << Lutaml::Model::XmlAdapter::Element.new("Element", method_name.to_s)
|
175
|
+
end
|
176
|
+
|
177
|
+
def plurimath_available?
|
178
|
+
Object.const_defined?(:Plurimath)
|
179
|
+
end
|
180
|
+
|
181
|
+
def nullify_mml_models
|
182
|
+
Plurimath::Mathml::Parser::CONFIGURATION.each_key { |klass| klass.model(klass) }
|
183
|
+
end
|
184
|
+
|
185
|
+
def reset_mml_models
|
186
|
+
::Mml::Configuration.custom_models = Plurimath::Mathml::Parser::CONFIGURATION
|
187
|
+
end
|
188
|
+
|
189
|
+
def update_options(options)
|
190
|
+
return options unless root
|
191
|
+
|
192
|
+
multiplier = options[:multiplier] || explicit_value&.dig(:multiplier)
|
193
|
+
options.merge(multiplier: multiplier).compact
|
194
|
+
end
|
171
195
|
end
|
172
196
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "unitsml/model/dimension_quantities/quantity"
|
4
|
+
require "unitsml/model/dimension_quantities/length"
|
5
|
+
require "unitsml/model/dimension_quantities/mass"
|
6
|
+
require "unitsml/model/dimension_quantities/time"
|
7
|
+
require "unitsml/model/dimension_quantities/electric_current"
|
8
|
+
require "unitsml/model/dimension_quantities/thermodynamic_temperature"
|
9
|
+
require "unitsml/model/dimension_quantities/amount_of_substance"
|
10
|
+
require "unitsml/model/dimension_quantities/luminous_intensity"
|
11
|
+
require "unitsml/model/dimension_quantities/plane_angle"
|
12
|
+
|
13
|
+
module Unitsml
|
14
|
+
module Model
|
15
|
+
class Dimension < Lutaml::Model::Serializable
|
16
|
+
attribute :id, :string
|
17
|
+
attribute :length, DimensionQuantities::Length
|
18
|
+
attribute :mass, DimensionQuantities::Mass
|
19
|
+
attribute :time, DimensionQuantities::Time
|
20
|
+
attribute :electric_current, DimensionQuantities::ElectricCurrent
|
21
|
+
attribute :thermodynamic_temperature, DimensionQuantities::ThermodynamicTemperature
|
22
|
+
attribute :amount_of_substance, DimensionQuantities::AmountOfSubstance
|
23
|
+
attribute :luminous_intensity, DimensionQuantities::LuminousIntensity
|
24
|
+
attribute :plane_angle, DimensionQuantities::PlaneAngle
|
25
|
+
|
26
|
+
xml do
|
27
|
+
root "Dimension"
|
28
|
+
namespace Unitsml::UNITSML_NS
|
29
|
+
|
30
|
+
map_attribute :id, to: :id, namespace: nil, prefix: "xml"
|
31
|
+
map_element :Length, to: :length
|
32
|
+
map_element :Mass, to: :mass
|
33
|
+
map_element :Time, to: :time
|
34
|
+
map_element :ElectricCurrent, to: :electric_current
|
35
|
+
map_element :ThermodynamicTemperature, to: :thermodynamic_temperature
|
36
|
+
map_element :AmountOfSubstance, to: :amount_of_substance
|
37
|
+
map_element :LuminousIntensity, to: :luminous_intensity
|
38
|
+
map_element :PlaneAngle, to: :plane_angle
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unitsml
|
4
|
+
module Model
|
5
|
+
module DimensionQuantities
|
6
|
+
class Quantity < Lutaml::Model::Serializable
|
7
|
+
attribute :symbol, :string
|
8
|
+
attribute :power_numerator, :string
|
9
|
+
|
10
|
+
xml do
|
11
|
+
map_attribute :symbol, to: :symbol
|
12
|
+
map_attribute :powerNumerator, to: :power_numerator
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "unitsml/model/prefixes/name"
|
4
|
+
require "unitsml/model/prefixes/symbol"
|
5
|
+
|
6
|
+
|
7
|
+
module Unitsml
|
8
|
+
module Model
|
9
|
+
class Prefix < Lutaml::Model::Serializable
|
10
|
+
attribute :name, Prefixes::Name
|
11
|
+
attribute :id, :string
|
12
|
+
attribute :symbol, Prefixes::Symbol, collection: true
|
13
|
+
attribute :prefix_base, :string
|
14
|
+
attribute :prefix_power, :string
|
15
|
+
|
16
|
+
xml do
|
17
|
+
root "Prefix"
|
18
|
+
namespace Unitsml::UNITSML_NS
|
19
|
+
|
20
|
+
map_attribute :prefixBase, to: :prefix_base
|
21
|
+
map_attribute :prefixPower, to: :prefix_power
|
22
|
+
map_attribute :id, to: :id, namespace: nil, prefix: "xml"
|
23
|
+
map_element :PrefixName, to: :name
|
24
|
+
map_element :PrefixSymbol, to: :symbol
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unitsml
|
4
|
+
module Model
|
5
|
+
class Prefixes
|
6
|
+
class Name < Lutaml::Model::Serializable
|
7
|
+
attribute :lang, :string, default: -> { "en" }
|
8
|
+
attribute :content, :string
|
9
|
+
|
10
|
+
xml do
|
11
|
+
root "PrefixName"
|
12
|
+
|
13
|
+
map_attribute :lang, to: :lang, namespace: nil, prefix: "xml", render_default: true
|
14
|
+
map_content to: :content
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unitsml
|
4
|
+
module Model
|
5
|
+
class Prefixes
|
6
|
+
class Symbol < Lutaml::Model::Serializable
|
7
|
+
attribute :type, :string
|
8
|
+
attribute :content, :string
|
9
|
+
|
10
|
+
xml do
|
11
|
+
root "PrefixSymbol"
|
12
|
+
|
13
|
+
map_attribute :type, to: :type
|
14
|
+
map_content to: :content
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|