Class: Pubid::Ccsds::Identifier::Base
- Inherits:
-
Pubid::Core::Identifier::Base
- Object
- Pubid::Core::Identifier::Base
- Pubid::Ccsds::Identifier::Base
- Extended by:
- Forwardable
- Defined in:
- lib/pubid/ccsds/identifier/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#book_color ⇒ Object
Returns the value of attribute book_color.
-
#retired ⇒ Object
Returns the value of attribute retired.
-
#series ⇒ Object
Returns the value of attribute series.
Class Method Summary collapse
- .get_parser_class ⇒ Object
- .get_renderer_class ⇒ Object
- .get_update_codes ⇒ Object
-
.transform(params) ⇒ Object
Use Identifier#create to resolve identifier’s type class.
- .transform_supplements(type, identifier_params) ⇒ Object
- .type ⇒ Object
Instance Method Summary collapse
-
#initialize(publisher: "CCSDS", book_color: nil, part: nil, series: nil, retired: nil, edition: nil, **opts) ⇒ Base
constructor
A new instance of Base.
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_color ⇒ Object
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 |
#retired ⇒ Object
Returns the value of attribute retired.
8 9 10 |
# File 'lib/pubid/ccsds/identifier/base.rb', line 8 def retired @retired end |
#series ⇒ Object
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_class ⇒ Object
46 47 48 |
# File 'lib/pubid/ccsds/identifier/base.rb', line 46 def get_parser_class Parser end |
.get_renderer_class ⇒ Object
50 51 52 |
# File 'lib/pubid/ccsds/identifier/base.rb', line 50 def get_renderer_class Renderer::Base end |
.get_update_codes ⇒ Object
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 |
.type ⇒ Object
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 |