Class: Pubid::Nist::Components::Supplement

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/pubid/nist/components/supplement.rb

Overview

Supplement component for NIST publications Represents supplement notation with number, year, month, or revision

Examples:

Supplement.new(number: "2").to_s(:short)              # => "supp2"
Supplement.new(year: "1925").to_s(:short)              # => "supp-1925"
Supplement.new(number: "3", year: "1926").to_s(:short) # => "supp3/1926"
Supplement.new(month: "Jan", year: "1924").to_s(:short) # => "suppJan1924"
Supplement.new(has_revision: true).to_s(:short)        # => "supprev"

Instance Method Summary collapse

Instance Method Details

#to_s(format = :short) ⇒ String

Render supplement in specified format

Parameters:

  • format (:short, :mr, :long) (defaults to: :short)

    The output format

Returns:

  • (String)

    The formatted supplement representation



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/pubid/nist/components/supplement.rb', line 33

def to_s(format = :short)
  return "" if number.nil? && year.nil? && !has_revision && suffix.nil? &&
    month_start.nil? && year_start.nil? && month_end.nil? && year_end.nil?

  case format
  when :short, :mr
    build_short_format
  when :long
    build_long_format
  else
    build_short_format
  end
end