Class: BeerXML::Recipe

Inherits:
Brewser::Recipe show all
Includes:
ROXML
Defined in:
lib/brewser/engines/beerxml.rb

Instance Method Summary collapse

Methods inherited from Brewser::Recipe

#as_json, json_create

Methods inherited from Brewser::Model

#as_beerxml, #as_brewson, auto_migrate_down!, auto_migrate_up!, auto_upgrade!, default_repository_name

Instance Method Details

#cleanupObject



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/brewser/engines/beerxml.rb', line 404

def cleanup
  self.recipe_volume = display_batch_size.present? ? display_batch_size.u : "#{uncast_batch_size} l".u 
  self.boil_volume = display_boil_size.present? ? display_boil_size.u : "#{uncast_boil_size} l".u
  self.type = style.type || "Other"
  mash_schedule.cleanup
  hops.each(&:cleanup)
  fermentables.each(&:cleanup)
  additives.each(&:cleanup)
  yeasts.each(&:cleanup)
  current_index = 1
  self.fermentation_schedule = BeerXML::FermentationSchedule.create
  ["primary_age","secondary_age","tertiary_age","age"].each do |stage|
    if self.send(stage).present? && self.send(stage).to_i > 0
      current_step = BeerXML::FermentationStep.new
      current_step.name = stage.split("_")[0].capitalize
      current_step.purpose = current_step.name
      current_step.purpose = "Conditioning" if current_step.purpose == "Age"
      current_step.index = current_index
      current_index += 1
      current_step.time = "#{self.send(stage)} days".u
      display = "display_#{stage.gsub("age","temp")}"
      uncast = "uncast_#{stage.gsub("age","temp")}"
      current_step.temperature = self.send(display).present? ? self.send(display).u : "#{self.send(uncast)} dC".u
      self.fermentation_schedule.fermentation_steps.push current_step
    end
  end
      
end