Class: ProMashTxt::Hop

Inherits:
Brewser::Hop show all
Defined in:
lib/brewser/engines/promash_txt.rb

Instance Method Summary collapse

Methods inherited from Brewser::Hop

#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

#from_promash(string) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/brewser/engines/promash_txt.rb', line 26

def from_promash(string)
  # String should look like this:
  # 3.00 oz.    Cascade                           Whole    4.35  46.6  60 min.
  self.amount = string[0..8].strip.u
  self.name = string[14..46].strip
  self.form = string[48..55].strip
  self.alpha_acids = string[56..61].strip.to_f
  time = string[69..77].strip
  case time
  when "Dry Hop"
    self.added_when = "Dry Hop"
  when "Mash H"
    self.added_when = "Mash"
  when "First WH"
    self.added_when = "First Wort"
  else
    self.added_when = "Boil"
    self.time = time.chop.u
  end
  return self
end