Class: Pubid::CenCenelec::Builder
- Inherits:
-
Builder::Base
- Object
- Builder::Base
- Pubid::CenCenelec::Builder
- Defined in:
- lib/pubid/cen_cenelec/builder.rb
Instance Attribute Summary
Attributes inherited from Builder::Base
Class Method Summary collapse
Instance Method Summary collapse
- #build(data) ⇒ Object
-
#initialize(scheme) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(scheme) ⇒ Builder
Returns a new instance of Builder.
6 7 8 |
# File 'lib/pubid/cen_cenelec/builder.rb', line 6 def initialize(scheme) @scheme = scheme end |
Class Method Details
Instance Method Details
#build(data) ⇒ Object
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 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pubid/cen_cenelec/builder.rb', line 14 def build(data) data = flatten_array(data) if data.is_a?(Array) # Store data for access in cast method @data = data # Check if this is a fragment identifier (AMD + FRAG) if data[:fragment_number] return build_fragment_identifier(data) end # Check if this is an adopted identifier (EN ISO, EN IEC, etc.) if data[:adopted_string] # Special case: ENV can adopt ISO/IEC standards if data[:publisher]&.to_s == "ENV" return build_env_adopted_identifier(data) end return build_adopted_identifier(data) end # Check if this is a standalone amendment/corrigendum (slash separator) if has_slash_supplements?(data) return build_standalone_supplement(data) end # Extract supplements before building base identifier (only plus/bundled) supplements_data = extract_supplements(data) # Determine identifier class using Scheme identifier = locate_identifier_klass(data).new assign_attributes(identifier, data) # Wrap with consolidated if supplements present (plus/bundled only) if supplements_data.any? wrap_with_consolidated(identifier, supplements_data) else identifier end end |