Class: Brewscribe::Grain
- Inherits:
-
Object
- Object
- Brewscribe::Grain
- Includes:
- Conversion
- Defined in:
- lib/brewscribe/grain.rb
Constant Summary collapse
- TYPES =
['Grain', 'Extract Sugar', 'Adjunct', 'Dry Extract']
- KEY_CONVERSION =
{ amount: FLOAT_CONV, color: FLOAT_CONV, yield: ->(k) { k.to_f * 0.01 }, price: FLOAT_CONV, boil_time: ->(k) { k.to_i }, percent: PERCENT_CONV, max_in_batch: PERCENT_CONV, add_after_boil: BOOLEAN_CONV, recommend_mash: BOOLEAN_CONV, in_recipe: BOOLEAN_CONV, type: ->(k) { TYPES[k.to_i] }, ibu_gal_per_lb: FLOAT_CONV, protein: PERCENT_CONV, diastatic_power: PERCENT_CONV, late_extract: FLOAT_CONV, moisture: PERCENT_CONV, coarse_fine_diff: PERCENT_CONV }
Constants included from Conversion
Conversion::BOOLEAN_CONV, Conversion::DATE_CONV, Conversion::FLOAT_CONV, Conversion::INT_CONV, Conversion::PERCENT_CONV
Instance Attribute Summary collapse
-
#add_after_boil ⇒ Object
readonly
Returns the value of attribute add_after_boil.
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#boil_time ⇒ Object
readonly
Returns the value of attribute boil_time.
-
#coarse_fine_diff ⇒ Object
readonly
Returns the value of attribute coarse_fine_diff.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#convert_grain ⇒ Object
readonly
Returns the value of attribute convert_grain.
-
#diastatic_power ⇒ Object
readonly
Returns the value of attribute diastatic_power.
-
#ibu_gal_per_lb ⇒ Object
readonly
Returns the value of attribute ibu_gal_per_lb.
-
#in_recipe ⇒ Object
readonly
Returns the value of attribute in_recipe.
-
#late_extract ⇒ Object
readonly
Returns the value of attribute late_extract.
-
#max_in_batch ⇒ Object
readonly
Returns the value of attribute max_in_batch.
-
#moisture ⇒ Object
readonly
Returns the value of attribute moisture.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#percent ⇒ Object
readonly
Returns the value of attribute percent.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#protein ⇒ Object
readonly
Returns the value of attribute protein.
-
#recommend_mash ⇒ Object
readonly
Returns the value of attribute recommend_mash.
-
#supplier ⇒ Object
readonly
Returns the value of attribute supplier.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#yield ⇒ Object
readonly
Returns the value of attribute yield.
Instance Method Summary collapse
- #in_pounds ⇒ Object
-
#initialize(grain_data) ⇒ Grain
constructor
A new instance of Grain.
- #ppg ⇒ Object
- #total_ppg ⇒ Object
Methods included from Conversion
Constructor Details
#initialize(grain_data) ⇒ Grain
Returns a new instance of Grain.
34 35 36 37 38 |
# File 'lib/brewscribe/grain.rb', line 34 def initialize grain_data @original_data = grain_data data_to_properties grain_data end |
Instance Attribute Details
#add_after_boil ⇒ Object (readonly)
Returns the value of attribute add_after_boil.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def add_after_boil @add_after_boil end |
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def amount @amount end |
#boil_time ⇒ Object (readonly)
Returns the value of attribute boil_time.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def boil_time @boil_time end |
#coarse_fine_diff ⇒ Object (readonly)
Returns the value of attribute coarse_fine_diff.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def coarse_fine_diff @coarse_fine_diff end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def color @color end |
#convert_grain ⇒ Object (readonly)
Returns the value of attribute convert_grain.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def convert_grain @convert_grain end |
#diastatic_power ⇒ Object (readonly)
Returns the value of attribute diastatic_power.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def diastatic_power @diastatic_power end |
#ibu_gal_per_lb ⇒ Object (readonly)
Returns the value of attribute ibu_gal_per_lb.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def ibu_gal_per_lb @ibu_gal_per_lb end |
#in_recipe ⇒ Object (readonly)
Returns the value of attribute in_recipe.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def in_recipe @in_recipe end |
#late_extract ⇒ Object (readonly)
Returns the value of attribute late_extract.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def late_extract @late_extract end |
#max_in_batch ⇒ Object (readonly)
Returns the value of attribute max_in_batch.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def max_in_batch @max_in_batch end |
#moisture ⇒ Object (readonly)
Returns the value of attribute moisture.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def moisture @moisture end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def name @name end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def notes @notes end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def origin @origin end |
#percent ⇒ Object (readonly)
Returns the value of attribute percent.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def percent @percent end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def price @price end |
#protein ⇒ Object (readonly)
Returns the value of attribute protein.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def protein @protein end |
#recommend_mash ⇒ Object (readonly)
Returns the value of attribute recommend_mash.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def recommend_mash @recommend_mash end |
#supplier ⇒ Object (readonly)
Returns the value of attribute supplier.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def supplier @supplier end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def type @type end |
#yield ⇒ Object (readonly)
Returns the value of attribute yield.
5 6 7 |
# File 'lib/brewscribe/grain.rb', line 5 def yield @yield end |
Instance Method Details
#in_pounds ⇒ Object
48 49 50 |
# File 'lib/brewscribe/grain.rb', line 48 def in_pounds self.amount / 16.0 end |
#ppg ⇒ Object
40 41 42 |
# File 'lib/brewscribe/grain.rb', line 40 def ppg self.yield * 46.214 end |
#total_ppg ⇒ Object
44 45 46 |
# File 'lib/brewscribe/grain.rb', line 44 def total_ppg ppg * in_pounds end |