Class: Pubid::Plateau::Identifiers::Base
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Pubid::Plateau::Identifiers::Base
- Defined in:
- lib/pubid/plateau/identifiers/base.rb
Overview
Base class for all PLATEAU identifiers
Direct Known Subclasses
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#base_hash ⇒ Object
Include type_string and annex in serialization for round-trip compatibility.
- #formatted_annex ⇒ Object
- #formatted_number ⇒ Object
-
#number ⇒ String
Generate URN for this identifier.
- #publisher ⇒ Object
-
#type_string ⇒ Object
Subclasses must implement type_string.
Methods inherited from 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_s, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code
Constructor Details
This class inherits a constructor from Pubid::Identifier
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/pubid/plateau/identifiers/base.rb', line 31 def ==(other) return false unless other.class == self.class number == other.number && annex == other.annex end |
#base_hash ⇒ Object
Include type_string and annex in serialization for round-trip compatibility
39 40 41 42 43 44 45 46 47 |
# File 'lib/pubid/plateau/identifiers/base.rb', line 39 def base_hash hash = super if self.class.attributes.key?(:type_string) && type_string hash[:type] = type_string end hash[:annex] = annex if annex hash end |
#formatted_annex ⇒ Object
27 28 29 |
# File 'lib/pubid/plateau/identifiers/base.rb', line 27 def formatted_annex annex ? "-#{annex}" : "" end |
#formatted_number ⇒ Object
23 24 25 |
# File 'lib/pubid/plateau/identifiers/base.rb', line 23 def formatted_number "#%02d" % number end |
#number ⇒ String
Generate URN for this identifier
11 |
# File 'lib/pubid/plateau/identifiers/base.rb', line 11 attribute :number, :integer |
#publisher ⇒ Object
14 15 16 |
# File 'lib/pubid/plateau/identifiers/base.rb', line 14 def publisher "PLATEAU" end |
#type_string ⇒ Object
Subclasses must implement type_string
19 20 21 |
# File 'lib/pubid/plateau/identifiers/base.rb', line 19 def type_string raise NotImplementedError, "Subclasses must implement type_string" end |