Class: Pubid::Jis::SupplementIdentifier
- Inherits:
-
Identifiers::Base
- Object
- Lutaml::Model::Serializable
- Identifier
- Identifiers::Base
- Pubid::Jis::SupplementIdentifier
- Defined in:
- lib/pubid/jis/supplement_identifier.rb
Overview
Base class for supplement identifiers (Amendment, Explanation) Supplements are modifications to base documents
Direct Known Subclasses
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#code ⇒ Object
Inherit code from base document.
-
#initialize(base:, number: nil, year: nil, **args) ⇒ SupplementIdentifier
constructor
A new instance of SupplementIdentifier.
-
#supplement_notation ⇒ Object
Override in subclasses.
-
#to_s(with_publisher: true) ⇒ Object
Render as base + supplement notation.
Methods inherited from Identifiers::Base
Methods inherited from Identifier
#base_identifier, #eql?, #exclude, #hash, #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
#initialize(base:, number: nil, year: nil, **args) ⇒ SupplementIdentifier
Returns a new instance of SupplementIdentifier.
11 12 13 14 15 16 17 18 |
# File 'lib/pubid/jis/supplement_identifier.rb', line 11 def initialize(base:, number: nil, year: nil, **args) @base = base @number = number # Year comes from parameter or base document supplement_year = year || base&.year # Call super with year to set it in Base super(year: supplement_year, **args) end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/pubid/jis/supplement_identifier.rb', line 37 def ==(other) return false unless other.is_a?(SupplementIdentifier) return false unless other.class == self.class base == other.base && number == other.number && year == other.year end |
#code ⇒ Object
Inherit code from base document
21 22 23 |
# File 'lib/pubid/jis/supplement_identifier.rb', line 21 def code base&.code end |
#supplement_notation ⇒ Object
Override in subclasses
33 34 35 |
# File 'lib/pubid/jis/supplement_identifier.rb', line 33 def supplement_notation raise NotImplementedError, "Subclass must implement supplement_notation" end |
#to_s(with_publisher: true) ⇒ Object
Render as base + supplement notation
26 27 28 29 30 |
# File 'lib/pubid/jis/supplement_identifier.rb', line 26 def to_s(with_publisher: true) result = base.to_s(with_publisher: with_publisher) result += "/#{supplement_notation}" result end |