Class: Pubid::Bsi::Identifiers::ConsolidatedIdentifier
Overview
Consolidated Identifier - contains base document plus supplements Example: “BS 4592-0:2006+A1:2012” = [BS 4592-0:2006, Amendment 1:2012]
Instance Method Summary
collapse
#<=>
parse
#from_hash, #polymorphic_type_map
Methods inherited from 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
Instance Method Details
#date ⇒ Object
49
50
51
52
|
# File 'lib/pubid/bsi/identifiers/consolidated_identifier.rb', line 49
def date
base = identifiers&.first
base.date if base&.class&.attributes&.key?(:date)
end
|
#number ⇒ Object
40
41
42
|
# File 'lib/pubid/bsi/identifiers/consolidated_identifier.rb', line 40
def number
identifiers&.first&.number
end
|
#part ⇒ Object
59
60
61
62
|
# File 'lib/pubid/bsi/identifiers/consolidated_identifier.rb', line 59
def part
base = identifiers&.first
base.part if base&.class&.attributes&.key?(:part)
end
|
#parts ⇒ Object
54
55
56
57
|
# File 'lib/pubid/bsi/identifiers/consolidated_identifier.rb', line 54
def parts
base = identifiers&.first
base.parts if base&.class&.attributes&.key?(:parts)
end
|
#publisher ⇒ Object
Delegate to first identifier (base document)
36
37
38
|
# File 'lib/pubid/bsi/identifiers/consolidated_identifier.rb', line 36
def publisher
identifiers&.first&.publisher
end
|
#to_s(lang: :en, lang_single: false) ⇒ Object
11
12
13
|
# File 'lib/pubid/bsi/identifiers/consolidated_identifier.rb', line 11
def to_s(lang: :en, lang_single: false)
render(format: :human, lang: lang, lang_single: lang_single)
end
|
#to_urn ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/pubid/bsi/identifiers/consolidated_identifier.rb', line 15
def to_urn
base = identifiers&.first
return nil unless base
urn = base.to_urn if base.class.method_defined?(:to_urn)
return urn unless urn
identifiers[1..].each do |id|
if id.is_a?(Amendment)
urn += ":amd:#{id.amendment_number}"
urn += ":#{id.amendment_year}" if id.amendment_year
elsif id.is_a?(Corrigendum)
urn += ":cor:#{id.corrigendum_number}"
urn += ":#{id.corrigendum_year}" if id.corrigendum_year
end
end
urn
end
|
#type ⇒ Object
64
65
66
67
|
# File 'lib/pubid/bsi/identifiers/consolidated_identifier.rb', line 64
def type
base = identifiers&.first
base.type if base&.class&.attributes&.key?(:type)
end
|
#year ⇒ Object
44
45
46
47
|
# File 'lib/pubid/bsi/identifiers/consolidated_identifier.rb', line 44
def year
base = identifiers&.first
base.year if base&.class&.attributes&.key?(:year)
end
|