Class: Pubid::Ccsds::Identifier::Base

Inherits:
Pubid::Core::Identifier::Base
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pubid/ccsds/identifier/base.rb

Direct Known Subclasses

Corrigendum

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(publisher: "CCSDS", book_color: nil, part: nil, series: nil, retired: nil, edition: nil, **opts) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
19
20
21
22
# File 'lib/pubid/ccsds/identifier/base.rb', line 14

def initialize(publisher: "CCSDS", book_color: nil, part: nil,
               series: nil, retired: nil, edition: nil, **opts)
  super(**opts.merge(publisher: publisher))
  @book_color = book_color.to_s
  @part = part.to_i || 0
  @series = series.to_s if series
  @retired = retired ? true : false
  @edition = edition.to_s if edition
end

Instance Attribute Details

#book_colorObject

Returns the value of attribute book_color.



8
9
10
# File 'lib/pubid/ccsds/identifier/base.rb', line 8

def book_color
  @book_color
end

#retiredObject

Returns the value of attribute retired.



8
9
10
# File 'lib/pubid/ccsds/identifier/base.rb', line 8

def retired
  @retired
end

#seriesObject

Returns the value of attribute series.



8
9
10
# File 'lib/pubid/ccsds/identifier/base.rb', line 8

def series
  @series
end

Class Method Details

.get_parser_classObject



46
47
48
# File 'lib/pubid/ccsds/identifier/base.rb', line 46

def get_parser_class
  Parser
end

.get_renderer_classObject



50
51
52
# File 'lib/pubid/ccsds/identifier/base.rb', line 50

def get_renderer_class
  Renderer::Base
end

.get_update_codesObject



54
55
56
# File 'lib/pubid/ccsds/identifier/base.rb', line 54

def get_update_codes
  UPDATE_CODES
end

.transform(params) ⇒ Object

Use Identifier#create to resolve identifier’s type class



35
36
37
38
39
40
41
42
43
44
# File 'lib/pubid/ccsds/identifier/base.rb', line 35

def transform(params)
  identifier_params = params.map do |k, v|
    get_transformer_class.new.apply(k => v)
  end.inject({}, :merge)

  %i(corrigendum).each do |type|
    return transform_supplements(type, identifier_params) if identifier_params[type]
  end
  Identifier.create(**identifier_params)
end

.transform_supplements(type, identifier_params) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/pubid/ccsds/identifier/base.rb', line 25

def transform_supplements(type, identifier_params)
  Identifier.create(
    type: type,
    base: transform(
      **identifier_params.dup.tap { |h| h.delete(type) }),
    **identifier_params[type],
    )
end

.typeObject



10
11
12
# File 'lib/pubid/ccsds/identifier/base.rb', line 10

def self.type
  { key: :ccsds, title: "The Consultative Committee for Space Data Systems" }
end