Class: Pubid::Ieee::UrnGenerator

Inherits:
UrnGenerator::Base show all
Defined in:
lib/pubid/ieee/urn_generator.rb

Instance Attribute Summary

Attributes inherited from UrnGenerator::Base

#identifier

Instance Method Summary collapse

Methods inherited from UrnGenerator::Base

#initialize, #maybe, #urn_edition, #urn_language, #urn_namespace, #urn_number, #urn_part, #urn_publisher, #urn_subpart, #urn_type, #urn_year

Constructor Details

This class inherits a constructor from Pubid::UrnGenerator::Base

Instance Method Details

#generateObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/pubid/ieee/urn_generator.rb', line 6

def generate
  parts = ["urn", "ieee"]

  parts << publisher_component

  special_type = special_identifier_type_component
  parts << special_type if special_type

  tc = type_component
  parts << tc if tc

  cc = code_component
  parts << cc if cc

  parts << identifier.year if identifier.year

  dc = draft_component
  parts << dc if dc

  ec = edition_component
  parts << ec if ec

  md = month_day_component
  parts << md if md

  ds = draft_status_component
  parts << ds if ds

  if !special_type && identifier.redline
    parts << "redline"
  end

  if !special_type && identifier.interpretation
    parts << "int"
  end

  if special_type != "conformance" && identifier.conf_number
    conf = "conf.#{identifier.conf_number}"
    conf += "-#{identifier.conf_year}" if identifier.conf_year
    parts << conf
  end

  if identifier.ashrae_number
    ashrae = "ashrae.#{identifier.ashrae_number}"
    ashrae += "-#{identifier.ashrae_year}" if identifier.ashrae_year
    parts << ashrae
  end

  if identifier.crossref
    parts << "xref.#{identifier.crossref}"
  end

  if identifier.relationships&.any?
    rel = identifier.relationships.join("/")
    parts << "rel.#{rel}"
  end

  if identifier.revision_of
    parts << "revof.#{identifier.revision_of}"
  end

  if identifier.amendment_to
    parts << "amdto.#{identifier.amendment_to}"
  end

  if identifier.adoption
    parts << "adopt.#{identifier.adoption}"
  end

  reaffirmed = maybe(:reaffirmed)
  if reaffirmed
    parts << "reaff.#{reaffirmed}"
  end

  if identifier.note
    parts << "note.#{identifier.note}"
  end

  if identifier.nickname
    parts << "nick.#{identifier.nickname}"
  end

  parts.join(":")
end