Class: Pubid::Idf::Builder

Inherits:
Builder::Base show all
Defined in:
lib/pubid/idf/builder.rb

Constant Summary collapse

LANG_CHAR_MAP =
{
  "R" => "ru",
  "F" => "fr",
  "E" => "en",
  "A" => "ar",
  "S" => "es",
  "D" => "de",
}.freeze

Instance Attribute Summary

Attributes inherited from Builder::Base

#identifier

Instance Method Summary collapse

Methods inherited from Builder::Base

#initialize

Constructor Details

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

Instance Method Details

#build(parsed_hash) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pubid/idf/builder.rb', line 15

def build(parsed_hash)
  typed_stage = Scheme.locate_typed_stage_by_abbr(parsed_hash[:type_with_stage])
  identifier = Scheme.locate_identifier_klass_by_type_code(typed_stage.type_code).new

  if type_with_stage_fr = parsed_hash.delete(:type_with_stage_fr)
    parsed_hash[:type_with_stage] = type_with_stage_fr
  end

  assign_attributes(identifier, parsed_hash)
  identifier
end