Class: Pubid::Components::Edition

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

Overview

Edition component (typically a year and number)

Instance Method Summary collapse

Instance Method Details

#original_formatObject

Method to get the original parsed format if needed



27
28
29
# File 'lib/pubid/components/edition.rb', line 27

def original_format
  original_text
end

#render(context: nil) ⇒ Object



22
23
24
# File 'lib/pubid/components/edition.rb', line 22

def render(context: nil)
  to_s
end

#to_sObject



11
12
13
14
15
# File 'lib/pubid/components/edition.rb', line 11

def to_s
  # Always use canonical format for rendering
  number_value = number.is_a?(Components::Code) ? number.value : number
  number_value ? "ED#{number_value}" : nil
end

#valueObject

V1 API compatibility - tests expect .value on edition itself



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

def value
  number.is_a?(Components::Code) ? number.value : number
end