beer_recipe 0.4.11 → 0.4.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/beer_recipe/mash_wrapper.rb +2 -0
- data/lib/beer_recipe/recipe_wrapper.rb +62 -19
- data/lib/beer_recipe/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1c69aef39b81784e559ab44b4c5bd5b6a372971
|
4
|
+
data.tar.gz: 81c43a22d05f859b7ebf5c0f49e65c6123cd4532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb7bb97935f5d937c226bf73fec7d5af7904b551f02fa01b08432dd024c0c21dbc253d8263fd622ed186dae27f0c92bfa0fd8d8673164e3ee640892c1549eec1
|
7
|
+
data.tar.gz: b98e1f9b232315b238f67ab508321064115de97f20ab950abae49cb49e3426ee266e9b903d0d35f549ba2e2558b6e2596db37c7794930e5245f824186112bfb2
|
@@ -6,12 +6,14 @@ class BeerRecipe::MashWrapper < BeerRecipe::Wrapper
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def steps
|
9
|
+
return [] if @record.nil?
|
9
10
|
@steps ||= @record.mash_steps.map do |step|
|
10
11
|
BeerRecipe::Wrapper.wrap(step, @recipe)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
15
|
def total_mash_time
|
16
|
+
return 0 if steps.empty?
|
15
17
|
steps.map { |s| s.step_time || 0 }.reduce :+ || 0
|
16
18
|
end
|
17
19
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
|
2
2
|
SETS = %i(fermentables hops miscs waters yeasts)
|
3
3
|
|
4
|
-
def initialize(record,
|
5
|
-
super
|
4
|
+
def initialize(record, actual_values: false)
|
5
|
+
super(record)
|
6
|
+
@actual_values = actual_values
|
6
7
|
@sets = {}
|
7
8
|
end
|
8
9
|
|
@@ -62,20 +63,40 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
|
|
62
63
|
strip_unit(recipe.est_fg)
|
63
64
|
end
|
64
65
|
|
66
|
+
def actual_og
|
67
|
+
recipe.og
|
68
|
+
end
|
69
|
+
|
70
|
+
def actual_fg
|
71
|
+
recipe.fg
|
72
|
+
end
|
73
|
+
|
65
74
|
def og
|
66
|
-
@og ||=
|
75
|
+
@og ||= @actual_values && actual_og > 0 ? actual_og : estimated_og || 0
|
67
76
|
end
|
68
77
|
|
69
78
|
def fg
|
70
|
-
@fg ||=
|
79
|
+
@fg ||= @actual_values && actual_fg > 0 ? actual_fg : estimated_fg || 0
|
80
|
+
end
|
81
|
+
|
82
|
+
def actual_abv
|
83
|
+
strip_unit(recipe.abv)
|
84
|
+
end
|
85
|
+
|
86
|
+
def estimated_abv
|
87
|
+
strip_unit(recipe.est_abv)
|
88
|
+
end
|
89
|
+
|
90
|
+
def calculated_abv
|
91
|
+
BeerRecipe::Formula.new.sg_to_abv(og, fg)
|
71
92
|
end
|
72
93
|
|
73
94
|
def abv
|
74
|
-
@abv ||=
|
95
|
+
@abv ||= @actual_values && actual_abv > 0 ? actual_abv : estimated_abv || calculated_abv
|
75
96
|
end
|
76
97
|
|
77
98
|
def ibu
|
78
|
-
@ibu ||=
|
99
|
+
@ibu ||= @actual_values && calculated_ibu > 0 ? calculated_ibu : estimated_ibu
|
79
100
|
end
|
80
101
|
|
81
102
|
def strip_unit(value)
|
@@ -83,15 +104,21 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
|
|
83
104
|
value.gsub(/ \w+\Z/, '').to_f
|
84
105
|
end
|
85
106
|
|
86
|
-
def
|
87
|
-
ibu
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
ibu
|
107
|
+
def estimated_ibu
|
108
|
+
strip_unit(recipe.ibu)
|
109
|
+
end
|
110
|
+
|
111
|
+
def calculated_ibu
|
112
|
+
@calculated_ibu ||= begin
|
113
|
+
ibu = 0
|
114
|
+
hops.each do |hop|
|
115
|
+
ibu += hop.ibu
|
116
|
+
end
|
117
|
+
bitter_extracts.each do |f|
|
118
|
+
ibu += f.ibu
|
119
|
+
end
|
120
|
+
ibu
|
93
121
|
end
|
94
|
-
ibu
|
95
122
|
end
|
96
123
|
|
97
124
|
def grains
|
@@ -102,8 +129,16 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
|
|
102
129
|
fermentables.select { |f| f.bitter_extract? }
|
103
130
|
end
|
104
131
|
|
132
|
+
def estimated_color
|
133
|
+
strip_unit(recipe.est_color)
|
134
|
+
end
|
135
|
+
|
105
136
|
def color
|
106
|
-
|
137
|
+
@actual_values ? actual_color : estimated_color
|
138
|
+
end
|
139
|
+
|
140
|
+
def actual_color
|
141
|
+
color_ebc
|
107
142
|
end
|
108
143
|
|
109
144
|
def color_mcu
|
@@ -119,7 +154,7 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
|
|
119
154
|
end
|
120
155
|
|
121
156
|
def color_ebc
|
122
|
-
@
|
157
|
+
@color_ebc ||= BeerRecipe::Formula.new.srm_to_ebc(color_srm)
|
123
158
|
end
|
124
159
|
|
125
160
|
def color_class
|
@@ -138,7 +173,7 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
|
|
138
173
|
end
|
139
174
|
|
140
175
|
def formatted_color
|
141
|
-
"#{'%.0f' %
|
176
|
+
"#{'%.0f' % color} EBC"
|
142
177
|
end
|
143
178
|
|
144
179
|
def total_grains
|
@@ -181,7 +216,15 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
|
|
181
216
|
|
182
217
|
# Returns calories per liter
|
183
218
|
def calories
|
184
|
-
@calories ||=
|
219
|
+
@calories ||= @actual_values && calculated_calories > 0 ? calculated_calories : estimated_calories
|
220
|
+
end
|
221
|
+
|
222
|
+
def estimated_calories
|
223
|
+
strip_unit(recipe.calories)
|
224
|
+
end
|
225
|
+
|
226
|
+
def calculated_calories
|
227
|
+
if has_final_values?
|
185
228
|
BeerRecipe::Formula.new.calories(serving_size, abv, og, fg)
|
186
229
|
else
|
187
230
|
0
|
@@ -189,7 +232,7 @@ class BeerRecipe::RecipeWrapper < BeerRecipe::Wrapper
|
|
189
232
|
end
|
190
233
|
|
191
234
|
def real_extract
|
192
|
-
@real_extract ||= if
|
235
|
+
@real_extract ||= if has_final_values?
|
193
236
|
BeerRecipe::Formula.new.real_extract(og, fg)
|
194
237
|
else
|
195
238
|
0
|
data/lib/beer_recipe/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beer_recipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olle Johansson
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.5.2
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Simple Beer XML recipe formatter.
|