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

Constant Summary

Constants inherited from Pubid::Iec::Identifier

Pubid::Iec::Identifier::IEC_TYPE_MAP

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SingleIdentifier

#edition_portion, #language_portion, #publisher_portion

Methods inherited from Pubid::Iec::Identifier

#all_parts_from_kv, #all_parts_to_kv, #build_code, build_type_map, #copublishers_from_kv, #copublishers_to_kv, default_publisher, #emit_code, from_hash, #number_from_kv, #number_to_kv, parse, #part_from_kv, #part_to_kv, published_typed_stage, #publisher_from_kv, #publisher_to_kv, #stage, #stage_from_kv, #stage_iteration_from_kv, #stage_iteration_to_kv, #stage_to_kv, #subpart_from_kv, #subpart_to_kv, #type, #year_from_kv, #year_to_kv

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, #year

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.typeObject

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/pubid/iec/identifiers/base.rb', line 44

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

Instance Method Details

#number_portionObject



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

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(**opts) ⇒ Object



23
24
25
# File 'lib/pubid/iec/identifiers/base.rb', line 23

def to_s(**opts)
  render(format: :human, **opts)
end

#validate!Object

Validate IEC-specific constraints



49
50
51
52
53
54
# File 'lib/pubid/iec/identifiers/base.rb', line 49

def validate!
  super if defined?(super)

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