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

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

Overview

Code component for NIST identifiers Handles number codes like series, volume, etc.

Instance Method Summary collapse

Instance Method Details

#partObject

Backward compatibility: extract part from compound numbers like “140-2” Returns the part number if the value contains a dash, nil otherwise



27
28
29
30
31
32
33
34
# File 'lib/pubid/nist/components/code.rb', line 27

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

  # Split by last dash to handle patterns like "4-4" (just number-part)
  # and "4-M-5" (which would return "M-5" as part)
  parts = number.to_s.split("-")
  parts.last if parts.length > 1
end

#to_sObject



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

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

#valueObject

Alias for compatibility



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

def value
  to_s
end