Class: NRB::BeerXML::Builder

Inherits:
Object
  • Object
show all
Includes:
Inflector
Defined in:
lib/nrb/beerxml/builder.rb

Constant Summary collapse

RECORDS =
%w( Equipment Fermentable Hop Mash MashStep Misc Recipe Style Water Yeast )

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Inflector

#camelize, #underscore

Class Method Details

.record_setsObject



9
# File 'lib/nrb/beerxml/builder.rb', line 9

def self.record_sets; records.map() { |type| "#{type}s" }; end

.recordsObject



8
# File 'lib/nrb/beerxml/builder.rb', line 8

def self.records; RECORDS; end

Instance Method Details

#build(type) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/nrb/beerxml/builder.rb', line 12

def build(type)
  if record_set? type
    RecordSet.new record_type: underscore(type.sub(/s$/,'')).to_sym
  else
    ::Module.nesting[1].const_get(type).new
  end
rescue NameError
  nil
end