Class: Pubid::Ieee::Ire::Builder
- Inherits:
-
Object
- Object
- Pubid::Ieee::Ire::Builder
- Defined in:
- lib/pubid/ieee/ire/builder.rb
Overview
Builder for IRE identifiers
Instance Method Summary collapse
Instance Method Details
#build(parsed) ⇒ Object
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 |
# File 'lib/pubid/ieee/ire/builder.rb', line 8 def build(parsed) attributes = {} # Extract publisher attributes[:publisher] = extract_value(parsed[:publisher]) # Extract type attributes[:type] = extract_value(parsed[:type]) # Extract the document designation. It travels as `code:` so the base # initializer parses it into `code_obj` and the CodeNumber mixin # hoists the flat split columns (number/prefix/parts/separator) that # relaton indexes on. number_str = extract_value(parsed[:number]) attributes[:code] = number_str if number_str # Extract year - handle both short (52) and full (1952) formats year_str = extract_value(parsed[:year]) if year_str year_int = year_str.to_i # Convert 2-digit years to 4-digit (12-63 => 1912-1963) if year_int.between?(12, 63) year_int += 1900 end attributes[:year] = year_int.to_s end # Override with full_year if present full_year_str = extract_value(parsed[:full_year]) if full_year_str attributes[:year] = full_year_str.to_i.to_s end # Create identifier Identifier.new(**attributes) end |