Class: Pubid::Astm::Identifiers::Standard

Inherits:
Base show all
Defined in:
lib/pubid/astm/identifiers/standard.rb

Direct Known Subclasses

IsoDualPublished

Instance Method Summary collapse

Methods inherited from Base

parse

Methods inherited from SingleIdentifier

#publisher

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



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pubid/astm/identifiers/standard.rb', line 11

def to_s
  parts = []
  parts << publisher if publisher

  # Code with potential dual unit
  if code
    code_str = code.to_s
    # Check if this is a dual unit designation
    if code.dual_m
      # F1862/F1862M format
      base_code = "#{code.letter}#{code.number}"
      code_str = "#{base_code}/#{base_code}M"
    end
    parts << code_str
  end

  # Join parts with space (ASTM E2938)
  result = parts.join(" ")

  # Append year directly without space
  if year
    result += "-#{year_portion}"
    result += sub_year if sub_year
  end

  # Append reapproval
  result += "(#{reapproval})" if reapproval

  # Append edition
  result += "e#{edition}" if edition

  result
end

#year_portionObject



45
46
47
48
# File 'lib/pubid/astm/identifiers/standard.rb', line 45

def year_portion
  # Convert 4-digit to 2-digit (e.g., 2015 → 15)
  year.to_s.length == 4 ? year.to_s[-2..] : year.to_s
end