Class: Pubid::Ccsds::SingleIdentifier
- Inherits:
-
Identifier
- Object
- Identifier
- Pubid::Ccsds::SingleIdentifier
- Defined in:
- lib/pubid/ccsds/single_identifier.rb
Instance Method Summary collapse
Methods included from Identifier
Instance Method Details
#<=>(other) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/pubid/ccsds/single_identifier.rb', line 50 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
19 20 21 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 |
# File 'lib/pubid/ccsds/single_identifier.rb', line 19 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 |