Class: Pubid::Iso::Components::Code

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

Overview

Code component for ISO identifiers.

Inherits value and parts from the shared Code; overrides rendering to join parts with “-” (ISO convention). Equality and hash are inherited from the shared Code (compare all fields).

Instance Method Summary collapse

Methods inherited from Components::Code

#eql?, #hash

Instance Method Details

#render(context: nil) ⇒ Object



18
19
20
# File 'lib/pubid/iso/components/code.rb', line 18

def render(context: nil)
  to_s
end

#to_sObject



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

def to_s
  result = value.to_s
  result += parts.map { |p| "-#{p}" }.join if parts&.any?
  result
end