rubeer 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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +0 -0
- data/LICENSE.txt +8 -0
- data/README.md +0 -0
- data/lib/rubeer/calculator/gravity/unit_converter.rb +30 -0
- data/lib/rubeer/version.rb +3 -0
- data/lib/rubeer.rb +2 -0
- metadata +105 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0d26c0a70a43f2ceb0eaa7a5c30cd5363828f9ba437f8abb40a21259a7bbb118
|
|
4
|
+
data.tar.gz: f4210b8d1eec812b80bf3bde45eb42dcb7843aa9560a44f4c2c1b75eb545fa3c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3c2117d914d4868170d09fa4a7119d4c9aac496565c3508692ac11304a099c424dbfb247c107a1404caf18b127ff7e987135d6e0fb4633614480c0ccf72f960f
|
|
7
|
+
data.tar.gz: a217cb49f87d203421fd66a129297a3399fb58160e78ad38251a86e57ed1884bc2176b6709c9b5cfdb4929ece14805507cefcdd2cc3006f99b1545f57f8ab5e3
|
data/CHANGELOG.md
ADDED
|
File without changes
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* "THE BEER-WARE LICENSE":
|
|
4
|
+
* <marchelmateusz@gmail.com> wrote this file. As long as you retain this notice you
|
|
5
|
+
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
6
|
+
* this stuff is worth it, you can buy me a beer in return. Stonefrog
|
|
7
|
+
* ----------------------------------------------------------------------------
|
|
8
|
+
*/
|
data/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Rubeer
|
|
2
|
+
module Calculator
|
|
3
|
+
module Gravity
|
|
4
|
+
class UnitConverter
|
|
5
|
+
# Brix, Plato and Balling differ on fifth/sixth decimal place
|
|
6
|
+
def specific_gravity_to_plato(gravity, round = 2)
|
|
7
|
+
rounded_gravity = ("%0.4f" % BigDecimal(1.2345.to_s)).split(".").last.insert(3, ".") # 1.0543 => 54.3
|
|
8
|
+
result = BigDecimal(259) - (BigDecimal(259) / BigDecimal(rounded_gravity))
|
|
9
|
+
result.round(round)
|
|
10
|
+
end
|
|
11
|
+
alias_method :sf_to_plato, :specific_gravity_to_plato
|
|
12
|
+
alias_method :specific_gravity_to_brix, :specific_gravity_to_plato
|
|
13
|
+
alias_method :sf_to_brix, :specific_gravity_to_plato
|
|
14
|
+
alias_method :specific_gravity_to_balling, :specific_gravity_to_plato
|
|
15
|
+
alias_method :sf_to_balling, :specific_gravity_to_plato
|
|
16
|
+
|
|
17
|
+
def plato_to_specific_gravity(plato, round = 4)
|
|
18
|
+
rounded_plato = BigDecimal(plato.to_s).round(2)
|
|
19
|
+
result = BigDecimal(259) / (BigDecimal(259) - rounded_plato)
|
|
20
|
+
result.round(round)
|
|
21
|
+
end
|
|
22
|
+
alias_method :plato_to_sf, :plato_to_specific_gravity
|
|
23
|
+
alias_method :brix_to_specific_gravity, :plato_to_specific_gravity
|
|
24
|
+
alias_method :brix_to_sf, :plato_to_specific_gravity
|
|
25
|
+
alias_method :balling_to_specific_gravity, :plato_to_specific_gravity
|
|
26
|
+
alias_method :balling_to_sf, :plato_to_specific_gravity
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/rubeer.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rubeer
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mateusz Marchel
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-02-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: bigdecimal
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '2'
|
|
69
|
+
description: A set of calculators to make homebrewing easier
|
|
70
|
+
email: marchelmateusz@gmail.com
|
|
71
|
+
executables: []
|
|
72
|
+
extensions: []
|
|
73
|
+
extra_rdoc_files: []
|
|
74
|
+
files:
|
|
75
|
+
- CHANGELOG.md
|
|
76
|
+
- LICENSE.txt
|
|
77
|
+
- README.md
|
|
78
|
+
- lib/rubeer.rb
|
|
79
|
+
- lib/rubeer/calculator/gravity/unit_converter.rb
|
|
80
|
+
- lib/rubeer/version.rb
|
|
81
|
+
homepage: https://rubygems.org/gems/rubeer
|
|
82
|
+
licenses:
|
|
83
|
+
- Beerware
|
|
84
|
+
metadata:
|
|
85
|
+
homepage_uri: https://rubygems.org/gems/rubeer
|
|
86
|
+
post_install_message:
|
|
87
|
+
rdoc_options: []
|
|
88
|
+
require_paths:
|
|
89
|
+
- lib
|
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
requirements: []
|
|
101
|
+
rubygems_version: 3.0.1
|
|
102
|
+
signing_key:
|
|
103
|
+
specification_version: 4
|
|
104
|
+
summary: Homebrewing calculators
|
|
105
|
+
test_files: []
|