Class: Pubid::Plateau::Identifiers::Base

Inherits:
Identifier
  • Object
show all
Defined in:
lib/pubid/plateau/identifiers/base.rb

Overview

Base class for all PLATEAU identifiers

Direct Known Subclasses

Handbook, TechnicalReport

Instance Method Summary collapse

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_hashObject

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_annexObject



27
28
29
# File 'lib/pubid/plateau/identifiers/base.rb', line 27

def formatted_annex
  annex ? "-#{annex}" : ""
end

#formatted_numberObject



23
24
25
# File 'lib/pubid/plateau/identifiers/base.rb', line 23

def formatted_number
  "#%02d" % number
end

#numberString

Generate URN for this identifier

Returns:

  • (String)

    URN representation



11
# File 'lib/pubid/plateau/identifiers/base.rb', line 11

attribute :number, :integer

#publisherObject



14
15
16
# File 'lib/pubid/plateau/identifiers/base.rb', line 14

def publisher
  "PLATEAU"
end

#type_stringObject

Subclasses must implement type_string

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/pubid/plateau/identifiers/base.rb', line 19

def type_string
  raise NotImplementedError, "Subclasses must implement type_string"
end