Class: Pubid::Amca::Identifiers::Publication

Inherits:
Base
  • Object
show all
Defined in:
lib/pubid/amca/identifiers/publication.rb

Overview

Publication identifier for ACMA publications Examples:

  • AMCA Publication 211-22 (Rev. 01-23)

  • AMCA Publication 311-16

  • AMCA Publication 1011-03 (R2010)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#base_hash, parse, #publisher, #to_urn

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(code:, year:, copublisher: nil, suffix: nil, reaffirmed: nil, revision: nil) ⇒ Publication

Returns a new instance of Publication.



14
15
16
17
18
19
20
21
22
# File 'lib/pubid/amca/identifiers/publication.rb', line 14

def initialize(code:, year:, copublisher: nil, suffix: nil,
reaffirmed: nil, revision: nil)
  @code = Components::Code.new(value: code.to_s)
  @year = Components::Date.new(year: year.to_s) if year
  @copublisher = copublisher
  @suffix = suffix
  @reaffirmed = reaffirmed
  @revision = revision
end

Instance Attribute Details

#revisionObject (readonly)

Returns the value of attribute revision.



12
13
14
# File 'lib/pubid/amca/identifiers/publication.rb', line 12

def revision
  @revision
end

Class Method Details

.typeObject



24
25
26
# File 'lib/pubid/amca/identifiers/publication.rb', line 24

def self.type
  { key: :publication, title: "Publication", short: nil }
end

Instance Method Details

#to_sString

Returns the rendered publication identifier.

Returns:

  • (String)

    the rendered publication identifier



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pubid/amca/identifiers/publication.rb', line 33

def to_s
  parts = []
  parts << @copublisher if @copublisher
  parts << "Publication"
  parts << @code.to_s
  parts << "-#{@year}" if @year
  parts << " (Rev. #{@revision})" if @revision
  parts << " (#{@reaffirmed})" if @reaffirmed && !@revision

  parts.join(" ").squeeze(" ")
end

#typeObject



28
29
30
# File 'lib/pubid/amca/identifiers/publication.rb', line 28

def type
  Publication.type
end