Class: Pubid::Iec::Identifiers::Base

Inherits:
SingleIdentifier show all
Defined in:
lib/pubid/iec/identifiers/base.rb

Overview

Base class for all IEC identifiers Inherits from SingleIdentifier to get common functionality Single Responsibility: Common IEC identifier attributes and behavior

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SingleIdentifier

#edition_portion, #language_portion, #publisher_portion

Methods inherited from Pubid::Iec::Identifier

parse

Methods inherited from Pubid::Identifier

#base_identifier, #eql?, #exclude, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, #render, #resolve_urn_generator, #root, #to_mr_string, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.typeObject

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/pubid/iec/identifiers/base.rb', line 61

def self.type
  raise NotImplementedError, "Subclass must implement self.type method"
end

Instance Method Details

#number_portionObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/pubid/iec/identifiers/base.rb', line 44

def number_portion
  return "" unless number

  result = " #{number}"

  # Add part if present
  result += "-#{part}" if part && part.to_s != ""

  # Add subpart if present
  result += "-#{subpart}" if subpart && subpart.to_s != ""

  # Add date if present
  result += ":#{date.year}" if date

  result
end

#to_s(_format = :short) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pubid/iec/identifiers/base.rb', line 23

def to_s(_format = :short)
  parts = []

  # Publisher and type portion (from typed_stage) - uses inherited method
  parts << publisher_portion

  # Number portion (number with part/subpart)
  parts << number_portion

  # Edition if present - add space before edition
  parts << " #{edition}" if edition&.number

  # VAP suffix
  parts << vap_suffix.render_with_space if vap_suffix

  # Database flag
  parts << " DB" if database

  parts.compact.join
end

#validate!Object

Validate IEC-specific constraints



66
67
68
69
70
71
72
73
74
# File 'lib/pubid/iec/identifiers/base.rb', line 66

def validate!
  super if defined?(super)

  # Validate VAP suffix if present
  vap_suffix&.validate!

  # Validate TRF info if present
  trf_info&.validate! if trf_info && !trf_info.empty?
end