beercalc 0.0.1
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 +72 -0
- metadata +45 -0
data/lib/beercalc.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
class Beercalc
|
2
|
+
|
3
|
+
## ABV()
|
4
|
+
# param og: number - original gravity
|
5
|
+
# param fg: number - final gravity
|
6
|
+
def self.abv(og, fg)
|
7
|
+
unless og < fg || !og.is_a?(Numeric) || !fg.is_a?(Numeric)
|
8
|
+
abv = (og - fg) * 131
|
9
|
+
else
|
10
|
+
abv = nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
## MCU()
|
15
|
+
# param weight: number - lbs of grain
|
16
|
+
# param lovibond: number - typically a number between
|
17
|
+
# param volume: number - gallons
|
18
|
+
def self.mcu(weight, lovibond, volume)
|
19
|
+
unless volume == 0 || !weight.is_a?(Numeric) || !lovibond.is_a?(Numeric) || !volume.is_a?(Numeric)
|
20
|
+
mcu = (weight * lovibond) / volume
|
21
|
+
else
|
22
|
+
mcu = nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
## SRM()
|
27
|
+
# param weight: number - lbs of grain
|
28
|
+
# param lovibond: number - typically a number between 1-25
|
29
|
+
# param volume: number - gallons
|
30
|
+
def self.srm(weight, lovibond, volume)
|
31
|
+
unless !weight.is_a?(Numeric) || !lovibond.is_a?(Numeric) || !volume.is_a?(Numeric)
|
32
|
+
srm = 1.4922 * (mcu(weight, lovibond, volume) ** 0.6859)
|
33
|
+
else
|
34
|
+
srm = nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
## AAU()
|
39
|
+
# param alpha: percent - alpha unit of the hop
|
40
|
+
# param weight: number - oz of hops
|
41
|
+
def self.aau(alpha, weight)
|
42
|
+
unless !alpha.is_a?(Numeric) || !weight.is_a?(Numeric)
|
43
|
+
aau = alpha * weight
|
44
|
+
else
|
45
|
+
aau = nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
## IBU()
|
50
|
+
# param alpha: percent - alpha unit of the hop
|
51
|
+
# param weight: number - oz of hops
|
52
|
+
# param utilization: number - output of self.utilization
|
53
|
+
# param volume: number - gallons
|
54
|
+
def self.ibu(alpha, weight, time, gravity, volume)
|
55
|
+
unless volume == 0 || !alpha.is_a?(Numeric) || !weight.is_a?(Numeric) || !time.is_a?(Numeric) || !gravity.is_a?(Numeric) || !volume.is_a?(Numeric)
|
56
|
+
ibu = self.aau(alpha, weight) * self.utilization(time, gravity) * 75 / volume
|
57
|
+
else
|
58
|
+
ibu = nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
## UTILIZATION()
|
63
|
+
# param time: number - minute hops are in the boil
|
64
|
+
# param gravity: number - gravity of the boil upon inserting Ex. 1.050
|
65
|
+
def self.utilization(time, gravity)
|
66
|
+
unless !time.is_a?(Numeric) || !gravity.is_a?(Numeric)
|
67
|
+
utilization = (1.65 * 0.000125**(gravity - 1)) * (1 - Math::E**(-0.04 * time)) / 4.15
|
68
|
+
else
|
69
|
+
utilization = nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: beercalc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ben Griffith
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-23 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Common beer calculations for brewers.
|
15
|
+
email: griffith.ben@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/beercalc.rb
|
21
|
+
homepage: http://rubygems.org/gems/beercalc
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 1.8.25
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: Common beer calculations for brewers.
|
45
|
+
test_files: []
|