Class: Pubid::Iec::Components::Sheet

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

Overview

Sheet component for IEC sheet notation Single Responsibility: Represents sheet number in IEC identifiers Example: IEC 60695-2-1/1:1994 (where /1 is the sheet)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(string) ⇒ Object

Parse sheet notation from string like “/1” or “1”



18
19
20
21
# File 'lib/pubid/iec/components/sheet.rb', line 18

def self.parse(string)
  number = string.to_s.gsub("/", "")
  new(number: number)
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/pubid/iec/components/sheet.rb', line 13

def to_s
  "/#{number}"
end

#validate!Object

Check if sheet number is valid (should be numeric)



24
25
26
27
28
# File 'lib/pubid/iec/components/sheet.rb', line 24

def validate!
  unless number.to_s.match?(/^\d+$/)
    raise ArgumentError, "Sheet number must be numeric: #{number}"
  end
end