Class: Pubid::Iec::SingleIdentifier
Instance Method Summary
collapse
Methods inherited from Identifier
parse
#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
Instance Method Details
#edition_portion(lang: :en) ⇒ Object
73
74
75
76
77
|
# File 'lib/pubid/iec/single_identifier.rb', line 73
def edition_portion(lang: :en)
return nil unless edition&.number
"ED#{edition.number}"
end
|
#language_portion(lang_single: false) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/pubid/iec/single_identifier.rb', line 61
def language_portion(lang_single: false)
return "" unless languages&.any?
[
"(",
languages.map do |lang|
lang.to_s(lang_single: lang_single)
end.join(lang_single ? "/" : ","),
")",
].join
end
|
#number_portion(lang_single: false) ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'lib/pubid/iec/single_identifier.rb', line 51
def number_portion(lang_single: false)
[
(number ? number.to_s : ""),
(part ? "-#{part}" : ""),
(subpart ? "-#{subpart}" : ""),
(stage_iteration ? ".#{stage_iteration}" : ""),
(date ? ":#{date.year}" : ""),
].join
end
|
#publisher_portion(lang: :en) ⇒ Object
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
|
# File 'lib/pubid/iec/single_identifier.rb', line 25
def publisher_portion(lang: :en)
pub_string = if copublishers&.any?
([publisher] + copublishers).map(&:body).join("/")
else
publisher.body
end
if typed_stage && !typed_stage.abbreviation.empty?
abbr = typed_stage.abbreviation
pub_string += if copublishers&.any? || abbr == ""
(abbr == "" ? "" : " #{abbr}")
else
"/#{abbr}"
end
end
pub_string
end
|
#to_s(lang: :en, lang_single: false, with_edition: false) ⇒ String
Generate URN for this identifier
15
16
17
18
19
20
21
22
23
|
# File 'lib/pubid/iec/single_identifier.rb', line 15
def to_s(lang: :en, lang_single: false, with_edition: false)
[].tap do |parts|
parts << publisher_portion(lang: lang)
parts << number_portion(lang_single: lang_single)
parts << edition_portion(lang: lang) if with_edition
end.compact.join(" ").tap do |s|
s << language_portion(lang_single: lang_single) if languages&.any?
end
end
|