beercalc 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/beercalc.rb +113 -0
- metadata +2 -2
data/lib/beercalc.rb
CHANGED
@@ -11,6 +11,18 @@ class Beercalc
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
## ABW()
|
15
|
+
# param og: number - original gravity
|
16
|
+
# param fg: number - final gravity
|
17
|
+
# SOURCE = http://hbd.org/ensmingr/
|
18
|
+
def self.abw(og, fg)
|
19
|
+
unless og < fg || !og.is_a?(Numeric) || !fg.is_a?(Numeric)
|
20
|
+
abv = (0.79 * self.abv(og, fg)) / fg
|
21
|
+
else
|
22
|
+
abv = nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
14
26
|
## MCU()
|
15
27
|
# param weight: number - lbs of grain
|
16
28
|
# param lovibond: number - typically a number between
|
@@ -69,4 +81,105 @@ class Beercalc
|
|
69
81
|
utilization = nil
|
70
82
|
end
|
71
83
|
end
|
84
|
+
|
85
|
+
## PLATO
|
86
|
+
# param sGravity: number - specific gravity
|
87
|
+
def self.plato(sGravity)
|
88
|
+
unless !sGravity.is_a?(Numeric)
|
89
|
+
plato = (-463.37) + (668.72 * sGravity) - (205.35 * sGravity**2)
|
90
|
+
else
|
91
|
+
plato = nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
## REAL EXTRACT
|
96
|
+
# param og: number - original gravity
|
97
|
+
# param fg: number - final gracivity
|
98
|
+
# SOURCE = http://hbd.org/ensmingr/
|
99
|
+
def self.realExtract(og, fg)
|
100
|
+
unless !og.is_a?(Numeric) || !fg.is_a?(Numeric) || og < fg
|
101
|
+
realExtract = (0.1808 * self.plato(og)) + (0.8192 * self.plato(fg))
|
102
|
+
else
|
103
|
+
realExtract = nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
## CALORIES (in 12 ounce increments)
|
108
|
+
# param og: number - original gravity
|
109
|
+
# param fg: number - final gravity
|
110
|
+
# SOURCE = http://hbd.org/ensmingr/
|
111
|
+
def self.calories(og, fg)
|
112
|
+
unless og < fg || !og.is_a?(Numeric) || !fg.is_a?(Numeric)
|
113
|
+
calories = ((6.9 * self.abw(og,fg)) + 4.0 * (self.realExtract(og,fg) - 0.1)) * fg * 3.55
|
114
|
+
else
|
115
|
+
calories = nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
## ATTENUATION
|
120
|
+
# param og: number - original gravity
|
121
|
+
# param fg: number - final gracivity
|
122
|
+
# Assuming this is in gravity (Ex. 1.054)
|
123
|
+
def self.attenuation(og, fg)
|
124
|
+
unless og < fg || !og.is_a?(Numeric) || !fg.is_a?(Numeric)
|
125
|
+
attenuation = (og - fg)/(og - 1)
|
126
|
+
else
|
127
|
+
attenuation = nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
## GRAVITY UNITS
|
132
|
+
# param g: number - gravity
|
133
|
+
def self.gu(g)
|
134
|
+
unless !g.is_a?(Numeric)
|
135
|
+
gu = ((g - 1) * 1000).round
|
136
|
+
else
|
137
|
+
gu = nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
## TOTAL GRAVITY
|
142
|
+
# param g: number - gravity
|
143
|
+
# param vol: number - volume in gallons
|
144
|
+
def self.totalGravity(g,v)
|
145
|
+
unless !g.is_a?(Numeric) || !v.is_a?(Numeric)
|
146
|
+
tg = self.gu(g) * v
|
147
|
+
else
|
148
|
+
tg = nil
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
## FINAL GRAVITY
|
153
|
+
# param g: number - initial gravity
|
154
|
+
# param vol_beg: number - volume in gallons at the begining of the boil
|
155
|
+
# param vol_end: number - volume in gallons at the end of the boil
|
156
|
+
def self.finalGravity(g, vol_beg, vol_end)
|
157
|
+
unless !g.is_a?(Numeric) || !vol_beg.is_a?(Numeric) || !vol_end.is_a?(Numeric)
|
158
|
+
gu = self.totalGravity(g,vol_beg) / vol_end
|
159
|
+
else
|
160
|
+
gu = nil
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
## EXTRACT ADDITION
|
165
|
+
# param target_gu: number - Target Total Gravity in Gravity Units
|
166
|
+
# param total_gu: number - Total Gravity from Mash in Gravity Units
|
167
|
+
# param extract: string/number - should be 'LME' or 'DME' or custom value
|
168
|
+
def self.extractAddition(target_gu, total_gu, extractType)
|
169
|
+
# Preset values for LME and DME, or account for a custom value
|
170
|
+
if extractType == 'LME'
|
171
|
+
extract = 38
|
172
|
+
elsif extractType == 'DME'
|
173
|
+
extract = 45
|
174
|
+
elsif extractType.is_a?(Numeric)
|
175
|
+
extract = extractType
|
176
|
+
end
|
177
|
+
|
178
|
+
unless !target_gu.is_a?(Numeric) || !total_gu.is_a?(Numeric) || !extract.is_a?(Numeric)
|
179
|
+
addition = (target_gu - total_gu).to_f / extract
|
180
|
+
else
|
181
|
+
addition = nil
|
182
|
+
end
|
183
|
+
return addition
|
184
|
+
end
|
72
185
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beercalc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
|
-
rubygems_version: 1.8.
|
41
|
+
rubygems_version: 1.8.23
|
42
42
|
signing_key:
|
43
43
|
specification_version: 3
|
44
44
|
summary: Common beer calculations for brewers.
|