Class: Pubid::Iso::Identifiers::TcDocument

Inherits:
Base show all
Defined in:
lib/pubid/iso/identifiers/tc_document.rb

Overview

Technical Committee Document Format: TC 184/SC 4/WG 3 N 123, JTC 1 N 456, TC 184 N 100

Constant Summary collapse

TC_TYPES =

TC types from ISO system

%w[TC JTC PC IT CAB CASCO COPOLCO COUNCIL CPSG CS DEVCO GA
GAAB INFCO ITN ISOlutions REMCO TMB TMBG WMO DMT JCG SGPM
ATMG CCCC CCCC-TG JDMT JSAG JSCTF-TF JTCG JTCG-TF SAG_Acc
SAG_CRMI SAG_CRMI_CG SAG_ESG SAG_ESG_CG SAG_MRS SAG_SF SAG_SF_CG
SMCC STMG MENA_STAR].freeze
WG_TYPES =

WG types from ISO system

%w[AG AhG WG JWG QC TF PPC CAG CSC ITSAG CSC/FIN CSC/NOM CSC/OVE
CSC/SP CSC SF ITSG JAG JCTF JSG JTAG JTG].freeze
TYPED_STAGES =

TC documents don’t use typed stages like other identifiers

[].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#copublishers, rendering_context

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, #urn_supplement_type, #urn_type_code

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.typeObject



36
37
38
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 36

def self.type
  { key: :tc, title: "Technical Committee Document", short: "TC" }
end

.typed_stagesObject



40
41
42
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 40

def self.typed_stages
  TYPED_STAGES
end

Instance Method Details

#==(other) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 93

def ==(other)
  return false unless other.is_a?(TcDocument)

  publisher == other.publisher &&
    tc_type == other.tc_type &&
    tc_number == other.tc_number &&
    sc_type == other.sc_type &&
    sc_number == other.sc_number &&
    wg_type == other.wg_type &&
    wg_number == other.wg_number &&
    number == other.number
end

#to_sObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 44

def to_s(...)
  result = publisher.to_s if publisher

  # Add TC type and number
  result += "/#{tc_type.value} " if tc_type&.value
  result += tc_number.value.to_s if tc_number&.value

  # Add SC type and number
  if sc_type&.value && sc_number&.value
    result += "/#{sc_type.value} "
    result += sc_number.value.to_s
  end

  # Add WG type and number
  if wg_type&.value && wg_number&.value
    result += "/#{wg_type.value} "
    result += wg_number.value.to_s
  end

  # Add document number
  result += " N #{number.value}" if number&.value

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

  result
end

#to_urnObject

Generate URN for TC document Format: urn:iso:doc:iso:tc:184:sc-4:wg-3:123



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 74

def to_urn
  parts = ["urn:iso:doc"]
  parts << publisher.to_s.downcase if publisher

  # Add TC
  parts << "tc:#{tc_number.value}" if tc_number&.value

  # Add SC
  parts << "sc-#{sc_number.value}" if sc_number&.value

  # Add WG
  parts << "wg-#{wg_number.value}" if wg_number&.value

  # Add document number
  parts << number.value if number&.value

  parts.join(":")
end