Class: Pubid::Nist::Identifiers::Handbook
- Defined in:
- lib/pubid/nist/identifiers/handbook.rb
Overview
NIST Handbook (HB) Examples:
- "NIST HB 130" = Handbook 130
- "NBS HB 133" = NBS Handbook 133
Constant Summary collapse
- TYPED_STAGES =
[ Pubid::Components::TypedStage.new( abbr: ["HB", "NIST HB", "NBS HB"], stage_code: "published", type_code: "hb", ), ].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #series_code ⇒ Object
-
#to_s(format = nil) ⇒ Object
Override to_s to handle edition+year pattern with dash instead of dot Pattern: "44e2-1955" (dash separator) not "44e2.1955" (dot separator).
Class Method Details
.type ⇒ Object
24 25 26 27 |
# File 'lib/pubid/nist/identifiers/handbook.rb', line 24 def type { key: :hb, web: :handbook, title: "NIST Handbook", short: "HB" } end |
.typed_stages ⇒ Object
20 21 22 |
# File 'lib/pubid/nist/identifiers/handbook.rb', line 20 def typed_stages TYPED_STAGES end |
Instance Method Details
#series_code ⇒ Object
30 31 32 |
# File 'lib/pubid/nist/identifiers/handbook.rb', line 30 def series_code "HB" end |
#to_s(format = nil) ⇒ Object
Override to_s to handle edition+year pattern with dash instead of dot Pattern: "44e2-1955" (dash separator) not "44e2.1955" (dot separator)
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pubid/nist/identifiers/handbook.rb', line 36 def to_s(format = nil) # Use the base to_s method first result = super # If edition has additional_text (year), replace dot with dash if edition&.additional_text && !edition.additional_text.empty? result = result.gsub(/#{Regexp.escape(edition.type)}#{Regexp.escape(edition.id)}\.#{Regexp.escape(edition.additional_text)}/, "#{edition.type}#{edition.id}-#{edition.additional_text}") end result end |