Class: Brewser::Fermentable

Inherits:
Model
  • Object
show all
Defined in:
lib/brewser/model/fermentable.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

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

Class Method Details

.json_create(o) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/brewser/model/fermentable.rb', line 32

def self.json_create(o)
  a = self.new
  a.name = o['name']
  a.origin = o['origin']
  a.supplier = o['supplier']
  a.description = o['description']      
  a.type = o['type']
  a.potential = o['potential']
  a.color = o['color']
  a.amount = o['amount'].u unless o['amount'].blank?
  a.late_addition = o['added_late']
  a.coarse_fine_diff = o['coarse_fine_diff']
  a.moisture = o['moisture']
  a.diastatic_power = o['diastatic_power']
  a.protein = o['protein']
  a.max_in_batch = o['max_in_batch']
  a.origin = o['origin']
  a.recommend_mash = o['recommend_mash']
  a.ibu_gal_per_lb = o['ibu_gal_per_lb']

  return a
end

Instance Method Details

#as_json(options = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/brewser/model/fermentable.rb', line 55

def as_json(options={})
  {
    JSON.create_id => "Brewser::Fermentable",
    'name' => name, 'origin' => origin, 
    'supplier' => supplier, 'description' => description,
    'type' => type, 'ppg' => ppg, 'potential' => potential, 
    'color' => color, 'amount' => amount.to_s, 'added_late' => late_addition?, 
    'coarse_fine_diff' => coarse_fine_diff, 'moisture' => moisture, 
    'diastatic_power' => diastatic_power, 'protein' => protein, 'max_in_batch' => max_in_batch, 
    'recommend_mash' => recommend_mash?, 'ibu_gal_per_lb' => ibu_gal_per_lb
  }
end

#ppgObject



27
28
29
30
# File 'lib/brewser/model/fermentable.rb', line 27

def ppg
  return 0 if potential.blank?
  (potential-1)*1000
end