Class: Pubid::Ccsds::SingleIdentifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Pubid::Ccsds::SingleIdentifier
- Defined in:
- lib/pubid/ccsds/single_identifier.rb
Overview
Qualified as ::Pubid::Identifier to avoid resolving to the local Pubid::Ccsds::Identifier module, which is a parser entry point (‘self.parse`) — not the base class.
Instance Method Summary collapse
Methods inherited from Identifier
#base_identifier, #eql?, #exclude, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, #render, #resolve_urn_generator, #root, #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
Instance Method Details
#<=>(other) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pubid/ccsds/single_identifier.rb', line 53 def <=>(other) return nil unless other.is_a?(SingleIdentifier) # Compare by number first num_cmp = number.value.to_i <=> other.number.value.to_i return num_cmp unless num_cmp.zero? # Then by part part_cmp = (part ? part.value.to_i : 0) <=> (other.part ? other.part.value.to_i : 0) return part_cmp unless part_cmp.zero? # Then by edition if edition && other.edition edition.number.to_s <=> other.edition.number.to_s elsif edition 1 elsif other.edition -1 else 0 end end |
#to_s(lang: :en, lang_single: false) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pubid/ccsds/single_identifier.rb', line 22 def to_s(lang: :en, lang_single: false) result = "" # Publisher result += publisher.body if publisher # Space after publisher result += " " # Series (optional single letter before number) result += series.value if series # Number with part (using dot notation) result += number.value result += ".#{part.value}" if part # Book color (required) - no space before dash result += "-#{book_color.value}" if book_color # Edition (optional) result += "-#{edition.number}" if edition # Retired marker (optional) result += "-S" if retired # Language (optional) result += " - #{language.code} Translated" if language result end |