Class: ProMashTxt::WaterProfile

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

Instance Method Summary collapse

Methods inherited from Brewser::WaterProfile

#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(array) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/brewser/engines/promash_txt.rb', line 105

def from_promash(array)
  self.name = /Profile:\s*(?<name>.*)/.match(array[0]){ |m| m[:name] } || "Unspecified"
  self.calcium = /(?<calcium>\S*)\sppm$/.match(array[2]){ |m| m[:calcium] }
  self.magnesium = /(?<magnesium>\S*)\sppm$/.match(array[3]){ |m| m[:magnesium] }
  self.sodium = /(?<sodium>\S*)\sppm$/.match(array[4]){ |m| m[:sodium] }
  self.sulfates = /(?<sulfate>\S*)\sppm$/.match(array[5]){ |m| m[:sulfate] }
  self.chloride = /(?<chloride>\S*)\sppm$/.match(array[6]){ |m| m[:chloride] }
  self.bicarbonate = /(?<bicarbonate>\S*)\sppm$/.match(array[7]){ |m| m[:bicarbonate] }
  self.ph = /(?<ph>\S*)$/.match(array[8]){ |m| m[:ph] }
  return self
end