Class: Pubid::Amca::SingleIdentifier

Inherits:
Identifiers::Base show all
Defined in:
lib/pubid/amca/single_identifier.rb

Overview

Base class for single (non-supplement) ACMA identifiers Includes: Standard, Publication

Instance Method Summary collapse

Methods inherited from Identifiers::Base

#base_hash, parse, #publisher, #to_urn

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_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code

Constructor Details

This class inherits a constructor from Pubid::Identifier

Instance Method Details

#to_sObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pubid/amca/single_identifier.rb', line 8

def to_s
  parts = []
  parts << copublisher if copublisher
  # type is a hash, get the title
  t = self.class.attributes.key?(:type) ? type : nil
  if t.is_a?(Hash) && t[:title]
    parts << t[:title].to_s
  end
  parts << code.to_s
  parts << "-#{year}" if year

  result = parts.compact.join(" ")

  # Handle additional copublisher after year (e.g., /ASHRAE 51-16)
  if copublisher&.include?("/") && year
    type_title = t.is_a?(Hash) ? t[:title].to_s : ""
    result = "#{copublisher} #{type_title} #{code}-#{year}"
  end

  result += " (#{reaffirmed})" if reaffirmed

  result
end