Class: BeerRecipe::HopWrapper
Instance Method Summary
collapse
Methods inherited from Wrapper
#blank?, #format_method, #initialize, #method_missing, #respond_to_missing?, set, wrap
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class BeerRecipe::Wrapper
Instance Method Details
#aau ⇒ Object
7
8
9
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 7
def aau
@record.alpha * amount * 0.035274
end
|
#adjust_bitterness(ibu) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 32
def adjust_bitterness(ibu)
if @record.form == 'Pellet'
ibu *= 1.10
elsif @record.form == 'Plug'
ibu *= 1.02
end
if @record.use == 'Mash'
ibu *= 0.20
elsif @record.use == 'First Wort'
ibu *= 1.10
elsif @record.use == 'Aroma'
ibu *= 0.50
end
ibu
end
|
#amount ⇒ Object
3
4
5
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 3
def amount
@record.amount * 1000
end
|
#amount_percent ⇒ Object
92
93
94
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 92
def amount_percent
amount / @recipe.total_hops * 100
end
|
#boil_time ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 60
def boil_time
if dryhop?
0
else
@record.time / 60
end
end
|
#calculate_ibu ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 20
def calculate_ibu
if has_needed_ibu_values? && contributes_bitterness?
ibu = BeerRecipe::Formula.new.tinseth(@recipe.batch_size, @record.time, @recipe.og, @record.alpha, amount)
ibu = adjust_bitterness(ibu)
ibu
else
0
end
end
|
#contributes_bitterness? ⇒ Boolean
48
49
50
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 48
def contributes_bitterness?
!dryhop?
end
|
#dryhop? ⇒ Boolean
56
57
58
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 56
def dryhop?
@record.use == 'Dry Hop' || @record.time > 320
end
|
84
85
86
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 84
def formatted_amount
"#{'%.0f' % amount}"
end
|
88
89
90
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 88
def formatted_ibu
"#{'%.1f' % ibu}"
end
|
68
69
70
71
72
73
74
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 68
def formatted_time
if dryhop?
"#{'%.0f' % (@record.time / 1440)}"
else
"#{'%.0f' % @record.time}"
end
end
|
#has_needed_ibu_values? ⇒ Boolean
52
53
54
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 52
def has_needed_ibu_values?
@recipe.has_final_values? && @recipe.batch_size > 0 && amount > 0 && @record.time > 0
end
|
#ibu ⇒ Object
16
17
18
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 16
def ibu
@ibu ||= calculate_ibu
end
|
#mgl_added_alpha_acids ⇒ Object
mg/l of added alpha acids
#time_unit ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/beer_recipe/hop_wrapper.rb', line 76
def time_unit
if dryhop?
'days'
else
'min'
end
end
|