rubybody 0.0.1 → 0.0.2
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 +13 -5
- data/README.md +8 -2
- data/lib/rubybody/calculations.rb +4 -4
- data/lib/rubybody/formulas.rb +3 -8
- data/lib/rubybody/nutrition.rb +26 -0
- data/lib/rubybody/person.rb +22 -18
- data/lib/rubybody/version.rb +1 -1
- data/lib/rubybody.rb +1 -1
- data/spec/formulas_spec.rb +3 -3
- data/spec/nutrition_spec.rb +8 -0
- data/spec/person_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZTkwMjQ1ZWMzNmRhZTNlMDg1MDk1OTQwZGUzZTNhY2U0NTk0MDU0Yg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDg2Nzc5MTFmZmY2OWUzYjI4YmRkZGQ0YTMyNzFiNjhmZjFjZjBkNQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YWI5NWUwZjkxZDk2YWRmNWUzOGM3ZmU2ZTliOTY4MTkzZWQ0N2NlMmVjN2Qz
|
10
|
+
N2FjMzE1OGE4NDI5MzRjMzExYjcwMWI4MzBhMWU1YjBjODE4YTUzM2VlODg0
|
11
|
+
NGQ2YjBiZDBjMDNkN2YzMjk3MDBiMzk3YzU2ZGQzZTVmMmI3ZTE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjVmMjA0NjQwZDE0ZDI3N2JiNDQyN2NlYTdjOTY3MzU5MzI2MjBkZjU1ZjIy
|
14
|
+
YTM3NGZkOTUzODY3OWJkOGQ2ZDc5NmM1Zjk5MDQyODAxY2ZiYWY2ZTFkMGJj
|
15
|
+
MzNhYTFlODZkYjM1NWI1NTg5ZTI1MjJjY2Q5ZDIzY2M2NjE2OGM=
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Rubybody
|
2
2
|
|
3
|
-
|
3
|
+
Rubybody provides calculations like TDEE, BMR and food calorie calculations
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,13 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
```ruby
|
22
|
+
person = Rubybody::Person.new(81, 188, 25, :male)
|
23
|
+
person.bmr #=> 1816
|
24
|
+
person.tdee #=> 2180
|
25
|
+
|
26
|
+
food = Rubybody::Food.new(10,5,2)
|
27
|
+
```
|
22
28
|
|
23
29
|
## Contributing
|
24
30
|
|
@@ -1,18 +1,18 @@
|
|
1
|
-
module
|
1
|
+
module Rubybody
|
2
2
|
|
3
3
|
def self.bmr(height, weight, age, gender, method)
|
4
4
|
case method.to_sym
|
5
5
|
when :mifflin_st_jeor
|
6
|
-
Formulas::
|
6
|
+
Formulas::mifflin_st_jeor(height, weight, age, gender)
|
7
7
|
when :harris_benedict
|
8
|
-
Formulas::
|
8
|
+
Formulas::harris_benedict(height, weight, age, gender)
|
9
9
|
else
|
10
10
|
raise "ArgumentError"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.tdee(bmr, activity_level)
|
15
|
-
Formulas::
|
15
|
+
Formulas::typical(bmr, activity_level)
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
data/lib/rubybody/formulas.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
module
|
1
|
+
module Rubybody
|
2
|
+
|
3
|
+
module Formulas
|
4
4
|
|
5
5
|
def self.mifflin_st_jeor(weight, height, age, gender)
|
6
6
|
|
@@ -28,10 +28,6 @@ module Formulas
|
|
28
28
|
|
29
29
|
end
|
30
30
|
|
31
|
-
end
|
32
|
-
|
33
|
-
module TDEE
|
34
|
-
|
35
31
|
def self.typical(bmr, activity_level)
|
36
32
|
|
37
33
|
case activity_level.to_sym
|
@@ -52,5 +48,4 @@ module Formulas
|
|
52
48
|
end
|
53
49
|
|
54
50
|
end
|
55
|
-
|
56
51
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Rubybody
|
2
|
+
|
3
|
+
PROTEIN_CALORIES = 4
|
4
|
+
CARB_CALORIES = 4
|
5
|
+
FAT_CALORIES = 9
|
6
|
+
ALCOHOL_CALORIES = 7
|
7
|
+
|
8
|
+
class Food
|
9
|
+
|
10
|
+
attr_accessor :protein, :carb, :fat, :alcohol
|
11
|
+
|
12
|
+
# All nutriments are expressed in grams
|
13
|
+
def initialize(protein, carb, fat, alcohol=0)
|
14
|
+
self.protein = protein
|
15
|
+
self.carb = carb
|
16
|
+
self.fat = fat
|
17
|
+
self.alcohol = alcohol
|
18
|
+
end
|
19
|
+
|
20
|
+
def calories
|
21
|
+
return self.protein * PROTEIN_CALORIES + self.carb * CARB_CALORIES + self.fat * FAT_CALORIES + self.alcohol * ALCOHOL_CALORIES
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/rubybody/person.rb
CHANGED
@@ -1,24 +1,28 @@
|
|
1
|
-
|
1
|
+
module Rubybody
|
2
|
+
|
3
|
+
class Person
|
2
4
|
|
3
|
-
|
5
|
+
attr_accessor :height, :weight, :age, :gender, :activity, :bodyfat, :waist
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
# All units are in the SI standard
|
8
|
+
def initialize(height, weight, age, gender, activity=:sedentary, bodyfat=0, waist=0)
|
9
|
+
self.height = height
|
10
|
+
self.weight = weight
|
11
|
+
self.age = age
|
12
|
+
self.gender = gender
|
13
|
+
self.activity = activity
|
14
|
+
self.bodyfat = bodyfat
|
15
|
+
self.waist = waist
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
def bmr(method=:mifflin_st_jeor)
|
19
|
+
Rubybody::bmr(height, weight, age, gender, method)
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
def tdee
|
23
|
+
Rubybody::tdee(bmr, activity)
|
24
|
+
end
|
23
25
|
|
26
|
+
end
|
27
|
+
|
24
28
|
end
|
data/lib/rubybody/version.rb
CHANGED
data/lib/rubybody.rb
CHANGED
data/spec/formulas_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Formulas
|
3
|
+
describe Rubybody::Formulas do
|
4
4
|
it "should return a bmr of 1851 for a 72 inches tall, 175lbs, 25 year old male" do
|
5
5
|
height = Unit("72 inches").to("cm").scalar.to_f
|
6
6
|
weight = Unit("175 lbs").to("kg").scalar.to_f
|
7
7
|
age = 25
|
8
8
|
gender = :male
|
9
|
-
Formulas::
|
9
|
+
Rubybody::Formulas::mifflin_st_jeor(weight, height, age, gender).to_i.should eql(1816)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should return a bmr of 1851 for a 72 inches tall, 175lbs, 25 year old female" do
|
@@ -14,6 +14,6 @@ describe Formulas::BMR do
|
|
14
14
|
weight = Unit("175 lbs").to("kg").scalar.to_f
|
15
15
|
age = 25
|
16
16
|
gender = :female
|
17
|
-
Formulas::
|
17
|
+
Rubybody::Formulas::mifflin_st_jeor(weight, height, age, gender).to_i.should eql(1650)
|
18
18
|
end
|
19
19
|
end
|
data/spec/person_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Person do
|
3
|
+
describe Rubybody::Person do
|
4
4
|
it "should return a bmr of 1851 for a 72 inches tall, 175lbs, 25 year old male" do
|
5
5
|
height = Unit("72 inches").to("cm").scalar.to_f
|
6
6
|
weight = Unit("175 lbs").to("kg").scalar.to_f
|
7
7
|
age = 25
|
8
8
|
gender = :male
|
9
|
-
person = Person.new(weight, height, age, gender)
|
9
|
+
person = Rubybody::Person.new(weight, height, age, gender)
|
10
10
|
person.bmr.to_i.should eql(1816)
|
11
11
|
person.tdee.to_i.should eql(2180)
|
12
12
|
end
|
@@ -16,7 +16,7 @@ describe Person do
|
|
16
16
|
weight = Unit("110 lbs").to("kg").scalar.to_f
|
17
17
|
age = 25
|
18
18
|
gender = :female
|
19
|
-
person = Person.new(weight, height, age, gender)
|
19
|
+
person = Rubybody::Person.new(weight, height, age, gender)
|
20
20
|
person.bmr.to_i.should eql(1244)
|
21
21
|
person.tdee.to_i.should eql(1493)
|
22
22
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubybody
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxime Santerre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: ruby-units
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '>='
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '>='
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Contains formulas for typical fitness calculations like TDEE, BMI and
|
@@ -82,10 +82,12 @@ files:
|
|
82
82
|
- lib/rubybody.rb
|
83
83
|
- lib/rubybody/calculations.rb
|
84
84
|
- lib/rubybody/formulas.rb
|
85
|
+
- lib/rubybody/nutrition.rb
|
85
86
|
- lib/rubybody/person.rb
|
86
87
|
- lib/rubybody/version.rb
|
87
88
|
- rubybody.gemspec
|
88
89
|
- spec/formulas_spec.rb
|
90
|
+
- spec/nutrition_spec.rb
|
89
91
|
- spec/person_spec.rb
|
90
92
|
- spec/spec_helper.rb
|
91
93
|
homepage: ''
|
@@ -98,22 +100,23 @@ require_paths:
|
|
98
100
|
- lib
|
99
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
102
|
requirements:
|
101
|
-
- - '>='
|
103
|
+
- - ! '>='
|
102
104
|
- !ruby/object:Gem::Version
|
103
105
|
version: '0'
|
104
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
107
|
requirements:
|
106
|
-
- - '>='
|
108
|
+
- - ! '>='
|
107
109
|
- !ruby/object:Gem::Version
|
108
110
|
version: '0'
|
109
111
|
requirements: []
|
110
112
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.1.5
|
112
114
|
signing_key:
|
113
115
|
specification_version: 4
|
114
116
|
summary: Formulas for fitness calculations
|
115
117
|
test_files:
|
116
118
|
- spec/formulas_spec.rb
|
119
|
+
- spec/nutrition_spec.rb
|
117
120
|
- spec/person_spec.rb
|
118
121
|
- spec/spec_helper.rb
|
119
122
|
has_rdoc:
|