Class: Pubid::Iho::Identifier::Base
- Inherits:
-
Core::Identifier::Base
- Object
- Core::Identifier::Base
- Pubid::Iho::Identifier::Base
- Defined in:
- lib/pubid/iho/identifier/base.rb
Instance Attribute Summary collapse
-
#appendix ⇒ Object
Returns the value of attribute appendix.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type:, publisher: "IHO", version: nil, part: nil, appendix: nil, **opts) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(type:, publisher: "IHO", version: nil, part: nil, appendix: nil, **opts) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pubid/iho/identifier/base.rb', line 10 def initialize(type:, publisher: "IHO", version: nil, part: nil, appendix: nil, **opts) super(**opts.merge(publisher: publisher)) @part = part.to_s if part @version = version.to_s if version @appendix = appendix.to_s if appendix if type unless Identifier.config.type_names.map { |_, v| v[:short] }.include?(type.to_s) raise Pubid::Core::Errors::WrongTypeError, "Type '#{type}' is not available" end @type = type.to_s end end |
Instance Attribute Details
#appendix ⇒ Object
Returns the value of attribute appendix.
4 5 6 |
# File 'lib/pubid/iho/identifier/base.rb', line 4 def appendix @appendix end |
#version ⇒ Object
Returns the value of attribute version.
4 5 6 |
# File 'lib/pubid/iho/identifier/base.rb', line 4 def version @version end |
Class Method Details
.get_parser_class ⇒ Object
32 33 34 |
# File 'lib/pubid/iho/identifier/base.rb', line 32 def get_parser_class Parser end |
.get_renderer_class ⇒ Object
36 37 38 |
# File 'lib/pubid/iho/identifier/base.rb', line 36 def get_renderer_class Renderer::Base end |
.transform(params) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/pubid/iho/identifier/base.rb', line 24 def transform(params) identifier_params = params.map do |k, v| get_transformer_class.new.apply(k => v) end.inject({}, :merge) Identifier.create(**identifier_params) end |
.type ⇒ Object
6 7 8 |
# File 'lib/pubid/iho/identifier/base.rb', line 6 def self.type { key: :iho } end |