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

Inherits:
Pubid::Iso::Identifier 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

Constants inherited from Pubid::Iso::Identifier

Pubid::Iso::Identifier::ISO_TYPE_MAP

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pubid::Iso::Identifier

#all_parts_from_kv, #all_parts_to_kv, #build_code, build_type_map, #copublishers_from_kv, #copublishers_to_kv, #date_for, #day_from_kv, #day_to_kv, default_publisher, #emit_code, #emit_date_part, from_hash, #month_from_kv, #month_to_kv, #number_from_kv, #number_to_kv, parse, #part_from_kv, #part_to_kv, published_typed_stage, #publisher_for, #publisher_from_kv, #publisher_to_kv, #stage, #stage_from_kv, #stage_iteration_from_kv, #stage_iteration_to_kv, #subpart_from_kv, #subpart_to_kv, #type, #with_harmonized_stage, #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, #urn_supplement_type, #urn_type_code, #year

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.typeObject



63
64
65
66
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 63

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

.typed_stagesObject



68
69
70
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 68

def self.typed_stages
  TYPED_STAGES
end

Instance Method Details

#==(other) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 122

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

#sc_number_from_kv(m, v) ⇒ Object



57
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 57

def sc_number_from_kv(m, v) = m.sc_number = build_code(v)

#sc_number_to_kv(m, doc) ⇒ Object



56
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 56

def sc_number_to_kv(m, doc) = emit_code(doc, "sc_number", m.sc_number)

#sc_type_from_kv(m, v) ⇒ Object



55
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 55

def sc_type_from_kv(m, v) = m.sc_type = build_code(v)

#sc_type_to_kv(m, doc) ⇒ Object



54
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 54

def sc_type_to_kv(m, doc) = emit_code(doc, "sc_type", m.sc_type)

#stage_to_kv(_model, _doc) ⇒ Object

TC documents have no stage; suppress the inherited stage emission.



48
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 48

def stage_to_kv(_model, _doc); end

#tc_number_from_kv(m, v) ⇒ Object



53
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 53

def tc_number_from_kv(m, v) = m.tc_number = build_code(v)

#tc_number_to_kv(m, doc) ⇒ Object



52
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 52

def tc_number_to_kv(m, doc) = emit_code(doc, "tc_number", m.tc_number)

#tc_type_from_kv(m, v) ⇒ Object



51
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 51

def tc_type_from_kv(m, v) = m.tc_type = build_code(v)

#tc_type_to_kv(m, doc) ⇒ Object



50
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 50

def tc_type_to_kv(m, doc) = emit_code(doc, "tc_type", m.tc_type)

#to_sObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 72

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

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

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

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

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

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

  result
end

#to_urnObject

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



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 102

def to_urn
  urn_ctx = Rendering::RenderingContext.urn
  parts = ["urn:iso:doc"]
  parts << publisher.render(context: urn_ctx) if publisher

  # Add TC
  parts << "tc:#{tc_number.render(context: urn_ctx)}" if tc_number&.value

  # Add SC
  parts << "sc-#{sc_number.render(context: urn_ctx)}" if sc_number&.value

  # Add WG
  parts << "wg-#{wg_number.render(context: urn_ctx)}" if wg_number&.value

  # Add document number
  parts << number.render(context: urn_ctx) if number&.value

  parts.join(":")
end

#wg_number_from_kv(m, v) ⇒ Object



61
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 61

def wg_number_from_kv(m, v) = m.wg_number = build_code(v)

#wg_number_to_kv(m, doc) ⇒ Object



60
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 60

def wg_number_to_kv(m, doc) = emit_code(doc, "wg_number", m.wg_number)

#wg_type_from_kv(m, v) ⇒ Object



59
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 59

def wg_type_from_kv(m, v) = m.wg_type = build_code(v)

#wg_type_to_kv(m, doc) ⇒ Object



58
# File 'lib/pubid/iso/identifiers/tc_document.rb', line 58

def wg_type_to_kv(m, doc) = emit_code(doc, "wg_type", m.wg_type)