Class: Pubid::CenCenelec::SingleIdentifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Identifier
- Pubid::CenCenelec::SingleIdentifier
- Defined in:
- lib/pubid/cen_cenelec/single_identifier.rb
Overview
The second of CEN/CENELEC's two identifier roots (the other is
Identifiers::Base); both descend from Pubid::CenCenelec::Identifier so every
concrete type is is_a? it.
Direct Known Subclasses
Identifiers::CenReport, Identifiers::CenWorkshopAgreement, Identifiers::CenelecHarmonizationDocument, Identifiers::EuropeanNorm, Identifiers::EuropeanPrestandard, Identifiers::EuropeanSpecification, Identifiers::Guide, Identifiers::HarmonizationDocument, Identifiers::TechnicalReport, Identifiers::TechnicalSpecification
Class Method Summary collapse
-
.type ⇒ String
Generate URN for this identifier.
Instance Method Summary collapse
Methods inherited from Identifier
Methods inherited from Identifier
#base_identifier, #eql?, #exclude, from_hash, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, polymorphic_type_map, #render, #resolve_urn_generator, #root, #to_hash, #to_mr_string, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year
Constructor Details
This class inherits a constructor from Pubid::Identifier
Class Method Details
.type ⇒ String
Generate URN for this identifier
17 18 19 |
# File 'lib/pubid/cen_cenelec/single_identifier.rb', line 17 def self.type nil end |
Instance Method Details
#<=>(other) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pubid/cen_cenelec/single_identifier.rb', line 25 def <=>(other) return nil unless other.is_a?(SingleIdentifier) # Compare by number first num_cmp = number.to_s <=> other.number.to_s return num_cmp unless num_cmp.zero? # Then by part part_cmp = (part || Components::Code.new(value: "0")).to_s <=> (other.part || Components::Code.new(value: "0")).to_s return part_cmp unless part_cmp.zero? # Then by date if date && other.date date.to_s <=> other.date.to_s elsif date 1 elsif other.date -1 else 0 end end |
#to_s(lang: :en, lang_single: false, **opts) ⇒ Object
21 22 23 |
# File 'lib/pubid/cen_cenelec/single_identifier.rb', line 21 def to_s(lang: :en, lang_single: false, **opts) render(format: :human, lang: lang, lang_single: lang_single, **opts) end |