Class: Pubid::Jcgm::Builder
Instance Attribute Summary
#identifier
Instance Method Summary
collapse
#initialize
Instance Method Details
#build(parsed_hash) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/pubid/jcgm/builder.rb', line 24
def build(parsed_hash)
identifier = locate_identifier_klass(parsed_hash).new
assign_attributes(identifier, parsed_hash)
if identifier.class.attributes.key?(:typed_stage) && identifier.typed_stage.nil?
default_typed_stage = Jcgm.locate_stage("") ||
raise(ArgumentError, "Unknown type abbreviation: ''")
identifier.typed_stage = default_typed_stage
identifier.stage = default_typed_stage.to_stage if identifier.class.attributes.key?(:stage)
identifier.type = default_typed_stage.to_type if identifier.class.attributes.key?(:type)
end
identifier
end
|
#locate_identifier_klass(parsed_hash) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/pubid/jcgm/builder.rb', line 6
def locate_identifier_klass(parsed_hash)
if parsed_hash[:base_identifier]
return Jcgm.locate_type(:amendment)
end
if parsed_hash[:gum_number]
return Jcgm.locate_type(:gum_guide)
end
return Jcgm.locate_type(:guide) unless parsed_hash[:type_with_stage]
typed_stage = locate_typed_stage(parsed_hash[:type_with_stage])
Jcgm.locate_type(typed_stage.type_code)
end
|