class NRB::BeerXML::RecordSet
Attributes
record_type[R]
records[R]
Public Class Methods
new(record_type: nil)
click to toggle source
# File lib/nrb/beerxml/record_set.rb, line 26 def initialize(record_type: nil) raise UnknownRecordTypeError.new("Don't know what to do with a #{record_type} record") unless valid_record_type?(record_type) @record_type = record_type @records = [] end
valid_record_types()
click to toggle source
# File lib/nrb/beerxml/record_set.rb, line 10 def self.valid_record_types %i( equipment fermentable hop mash mash_step misc recipe style water yeast ) end
Public Instance Methods
<<(record)
click to toggle source
# File lib/nrb/beerxml/record_set.rb, line 15 def <<(record) raise UnknownRecordTypeError.new("Can't add a #{record.record_type} to this set (only #{record_type}s)") unless valid_record_type?(record.record_type) @records << record end
each(&block)
click to toggle source
# File lib/nrb/beerxml/record_set.rb, line 21 def each(&block) @records.each &block end
record_count()
click to toggle source
# File lib/nrb/beerxml/record_set.rb, line 33 def record_count @records.size end
Private Instance Methods
valid_record_type?(type)
click to toggle source
# File lib/nrb/beerxml/record_set.rb, line 39 def valid_record_type?(type) self.class.valid_record_types.include?(type) end