Class: Pubid::Etsi::Identifiers::EtsiStandard
Overview
Single class for all ETSI standard types
Type is passed as parameter: EN, ES, EG, TS, ETR, ETS, I-ETS, TBR,
TCRTR, NET, GR, GS, SR, TR, GTS
Format: ETSI TYPE CODE VERSION (DATE)
Examples:
ETSI GS ZSM 012 V1.1.1 (2022-12)
ETSI GR ZSM 009-3 V1.1.1 (2023-08)
ETSI GTS GSM 02.01 V5.5.0 (1999-01)
Instance Method Summary
collapse
-
#code_for(model) ⇒ Object
-
#date_for(model) ⇒ Object
-
#day_from_kv(model, value) ⇒ Object
-
#day_to_kv(model, doc) ⇒ Object
-
#edition_from_kv(model, value) ⇒ Object
-
#edition_to_kv(model, doc) ⇒ Object
-
#emit_kv(doc, key, value) ⇒ Object
-
#minor_from_kv(model, value) ⇒ Object
-
#minor_to_kv(model, doc) ⇒ Object
-
#month_from_kv(model, value) ⇒ Object
-
#month_to_kv(model, doc) ⇒ Object
-
#number_from_kv(model, value) ⇒ Object
-
#number_to_kv(model, doc) ⇒ Object
--- Code component flattened to bare number / parts / minor ---.
-
#parts_from_kv(model, value) ⇒ Object
-
#parts_to_kv(model, doc) ⇒ Object
-
#version_for(model) ⇒ Object
-
#version_from_kv(model, value) ⇒ Object
-
#version_to_kv(model, doc) ⇒ Object
--- Version flattened to scalar version + is_edition flag ---.
-
#year_from_kv(model, value) ⇒ Object
-
#year_to_kv(model, doc) ⇒ Object
--- Date flattened to top-level year/month/day scalars ---.
#==, parse
Methods inherited from Identifier
apply_mappings, #base, #base_document, concrete_class_for, #dated_version_of?, #draft_of?, #drop_supplements, #edition_of?, #eql?, #exclude, from_hash, #has_supplement?, #hash, #includes?, #initialize, #matches?, #mr_all_parts, #mr_edition, #mr_languages, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_subpart, #mr_supplement_suffix, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, polymorphic_type_map, #related_to?, #render, #resolve_urn_generator, #root, #sibling_of?, #supplement_of?, #to_hash, #to_mr_string, #to_s, #to_slug, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year
Instance Method Details
#code_for(model) ⇒ Object
129
130
131
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 129
def code_for(model)
model.code ||= Pubid::Etsi::Components::Code.new
end
|
#date_for(model) ⇒ Object
137
138
139
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 137
def date_for(model)
model.date ||= Pubid::Components::Date.new
end
|
#day_from_kv(model, value) ⇒ Object
117
118
119
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 117
def day_from_kv(model, value)
date_for(model).day = value.to_s
end
|
#day_to_kv(model, doc) ⇒ Object
105
106
107
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 105
def day_to_kv(model, doc)
emit_kv(doc, "day", model.date&.day)
end
|
#edition_from_kv(model, value) ⇒ Object
92
93
94
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 92
def edition_from_kv(model, value)
version_for(model).is_edition = value
end
|
#edition_to_kv(model, doc) ⇒ Object
84
85
86
87
88
89
90
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 84
def edition_to_kv(model, doc)
return unless model.version&.is_edition
doc.add_child(
Lutaml::KeyValue::DataModel::Element.new("is_edition", true),
)
end
|
#emit_kv(doc, key, value) ⇒ Object
121
122
123
124
125
126
127
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 121
def emit_kv(doc, key, value)
return if value.nil? || value.to_s.empty?
doc.add_child(
Lutaml::KeyValue::DataModel::Element.new(key, value.to_s),
)
end
|
#minor_from_kv(model, value) ⇒ Object
56
57
58
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 56
def minor_from_kv(model, value)
code_for(model).minor = value.to_s
end
|
#minor_to_kv(model, doc) ⇒ Object
52
53
54
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 52
def minor_to_kv(model, doc)
emit_kv(doc, "minor", model.code&.minor)
end
|
#month_from_kv(model, value) ⇒ Object
113
114
115
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 113
def month_from_kv(model, value)
date_for(model).month = value.to_s
end
|
#month_to_kv(model, doc) ⇒ Object
101
102
103
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 101
def month_to_kv(model, doc)
emit_kv(doc, "month", model.date&.month)
end
|
#number_from_kv(model, value) ⇒ Object
48
49
50
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 48
def number_from_kv(model, value)
code_for(model).number = value.to_s
end
|
#number_to_kv(model, doc) ⇒ Object
--- Code component flattened to bare number / parts / minor ---
44
45
46
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 44
def number_to_kv(model, doc)
emit_kv(doc, "number", model.code&.number)
end
|
#parts_from_kv(model, value) ⇒ Object
71
72
73
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 71
def parts_from_kv(model, value)
code_for(model).parts = Array(value).map(&:to_s)
end
|
#parts_to_kv(model, doc) ⇒ Object
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 60
def parts_to_kv(model, doc)
parts = model.code&.parts
return if parts.nil? || parts.empty?
doc.add_child(
Lutaml::KeyValue::DataModel::Element.new(
"parts", parts.map(&:to_s)
),
)
end
|
#version_for(model) ⇒ Object
133
134
135
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 133
def version_for(model)
model.version ||= Pubid::Etsi::Components::Version.new
end
|
#version_from_kv(model, value) ⇒ Object
80
81
82
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 80
def version_from_kv(model, value)
version_for(model).version = value.to_s
end
|
#version_to_kv(model, doc) ⇒ Object
--- Version flattened to scalar version + is_edition flag ---
76
77
78
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 76
def version_to_kv(model, doc)
emit_kv(doc, "version", model.version&.version)
end
|
#year_from_kv(model, value) ⇒ Object
109
110
111
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 109
def year_from_kv(model, value)
date_for(model).year = value.to_s
end
|
#year_to_kv(model, doc) ⇒ Object
--- Date flattened to top-level year/month/day scalars ---
97
98
99
|
# File 'lib/pubid/etsi/identifiers/etsi_standard.rb', line 97
def year_to_kv(model, doc)
emit_kv(doc, "year", model.date&.year)
end
|