Class: Pubid::Nist::Components::Code

Inherits:
Components::Code
  • Object
show all
Defined in:
lib/pubid/nist/components/code.rb

Overview

Code component for NIST identifiers.

Inherits value and subpart from the shared Code; overrides rendering to compose compound numbers like “1234.5” (subpart joined with “.” per NIST convention).

Instance Method Summary collapse

Methods inherited from Components::Code

#eql?, #hash, #render

Instance Method Details

#partObject



18
19
20
21
22
23
# File 'lib/pubid/nist/components/code.rb', line 18

def part
  return nil unless value&.include?("-")

  parts = value.to_s.split("-")
  parts.last if parts.length > 1
end

#to_sObject



12
13
14
15
16
# File 'lib/pubid/nist/components/code.rb', line 12

def to_s
  result = value.to_s
  result += ".#{subpart}" if subpart
  result
end