Class: Pubid::Plateau::Builder
- Inherits:
-
Object
- Object
- Pubid::Plateau::Builder
- Defined in:
- lib/pubid/plateau/builder.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build(parsed) ⇒ Object
6 7 8 |
# File 'lib/pubid/plateau/builder.rb', line 6 def self.build(parsed) new.build(parsed) end |
Instance Method Details
#build(parsed) ⇒ Object
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 |
# File 'lib/pubid/plateau/builder.rb', line 10 def build(parsed) # Check for annex supplement first if parsed[:base] && parsed[:annex_letter] return build_annex(parsed) end # Determine which class to use based on type klass = case parsed[:type].to_s when "Handbook" Identifiers::Handbook when "Technical Report" Identifiers::TechnicalReport else raise "Unknown PLATEAU type: #{parsed[:type]}" end # Build parameters common to all types params = { number: parsed[:number].to_s.to_i, } params[:annex] = parsed[:annex].to_s.to_i if parsed[:annex] # Only Handbook carries an edition; a legacy Latin TR captures the # edition slice via the shared handbook rule, so drop it here. if parsed[:edition] && klass == Identifiers::Handbook params[:edition] = parsed[:edition].to_s end klass.new(**params) end |