Class: Pubid::Iso::Identifiers::Base
- Inherits:
-
Pubid::Identifier
- Object
- Lutaml::Model::Serializable
- Pubid::Identifier
- Pubid::Iso::Identifiers::Base
- Defined in:
- lib/pubid/iso/identifiers/base.rb
Overview
Base class for ISO identifiers
Direct Known Subclasses
Class Method Summary collapse
-
.rendering_context ⇒ Object
ISO rendering context singleton.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#copublishers ⇒ Object
V1 API compatibility - tests expect .copublishers returning array of Publisher objects.
-
#to_s(lang: :en, lang_single: false, with_edition: false) ⇒ String
Render identifier using OOP approach - each component renders itself.
Methods inherited from Pubid::Identifier
#base_identifier, #eql?, #exclude, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, #render, #resolve_urn_generator, #root, #to_mr_string, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code
Constructor Details
This class inherits a constructor from Pubid::Identifier
Class Method Details
.rendering_context ⇒ Object
ISO rendering context singleton
15 16 17 |
# File 'lib/pubid/iso/identifiers/base.rb', line 15 def self.rendering_context @rendering_context ||= Pubid::Rendering::RenderingContext.iso end |
Instance Method Details
#==(other) ⇒ Object
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/pubid/iso/identifiers/base.rb', line 102 def ==(other) return false unless other.is_a?(Base) publisher == other.publisher && type == other.type && number == other.number && part == other.part && date == other.date && stage == other.stage end |
#copublishers ⇒ Object
V1 API compatibility - tests expect .copublishers returning array of Publisher objects
94 95 96 97 98 99 100 |
# File 'lib/pubid/iso/identifiers/base.rb', line 94 def copublishers return [] unless publisher.copublisher&.any? publisher.copublisher.map do |cp| ::Pubid::Components::Publisher.new(body: cp) end end |
#to_s(lang: :en, lang_single: false, with_edition: false) ⇒ String
Render identifier using OOP approach - each component renders itself
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pubid/iso/identifiers/base.rb', line 25 def to_s(lang: :en, lang_single: false, with_edition: false) # Create rendering context with language settings context = Pubid::Rendering::RenderingContext.new( stage_separator: "/", stage_separator_with_copublisher: " ", type_separator: "/", type_separator_with_prefix: " ", default_type_abbr: "IS", lang: lang, lang_single: lang_single, ) # Compose the identifier from component renderings render_from_components(context: context, with_edition: with_edition) end |