Class: Pubid::Ccsds::Identifiers::Base

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Includes:
Serializable
Defined in:
lib/pubid/ccsds/identifiers/base.rb,
lib/pubid/ccsds/identifiers/base_BASE_88929.rb

Overview

CCSDS identifier Format: CCSDS NUMBER.PART-TYPE-EDITION Example: CCSDS 120.0-G-4, CCSDS 100.0-G-1-S

Constant Summary collapse

TYPED_STAGES =
[
  Pubid::Components::TypedStage.new(
    abbr: [""],
    stage_code: "published",
    type_code: "base",
  ),
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.typeObject



23
24
25
# File 'lib/pubid/ccsds/identifiers/base.rb', line 23

def self.type
  { key: :base, web: :base, title: "Base Standard", short: nil }
end

Instance Method Details

#==(other) ⇒ Object



57
58
59
60
61
62
63
64
65
66
# File 'lib/pubid/ccsds/identifiers/base_BASE_88929.rb', line 57

def ==(other)
  return false unless other.is_a?(Base)

  number == other.number &&
    part == other.part &&
    type == other.type &&
    edition == other.edition &&
    suffix == other.suffix &&
    language == other.language
end

#base_hashObject

Include CCSDS-specific attributes in serialization



24
25
26
27
28
29
30
31
# File 'lib/pubid/ccsds/identifiers/base_BASE_88929.rb', line 24

def base_hash
  hash = super
  # CCSDS uses plain strings for type, edition, suffix
  hash[:type] = type if type
  hash[:suffix] = suffix if suffix
  hash[:language] = language if language
  hash
end

#publisherObject



40
41
42
# File 'lib/pubid/ccsds/identifiers/base_BASE_88929.rb', line 40

def publisher
  "CCSDS"
end

#to_sObject



27
28
29
30
31
32
33
34
35
# File 'lib/pubid/ccsds/identifiers/base.rb', line 27

def to_s(**_opts)
  result = "#{publisher} #{number}"
  result += ".#{part}" if part
  result += "-#{type}" if type
  result += "-#{edition}" if edition
  result += "-#{suffix}" if suffix
  result += " - #{language} Translated" if language
  result
end

#to_urnString

Generate URN for this identifier

Returns:

  • (String)

    URN representation



19
20
21
# File 'lib/pubid/ccsds/identifiers/base_BASE_88929.rb', line 19

def to_urn
  UrnGenerator.new(self).generate
end