rubybody 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.
- checksums.yaml +8 -8
- data/README.md +15 -1
- data/lib/rubybody/calculations.rb +3 -3
- data/lib/rubybody/formulas.rb +5 -5
- data/lib/rubybody/nutrition.rb +7 -7
- data/lib/rubybody/person.rb +5 -5
- data/lib/rubybody/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2ZhOTdiNjUzZTMxZWRjYTkwZjM5MzEwNDVhNjdhMTQ2NThjMzZiZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWI3NmUxMGE1OWNiNTBiZTI4MWUzNjA3MDAwODEwY2YyMTA0ZTAxNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmZmOTViNDZlMDAxZDI0NjczOGJhNWFiODM1NzgxN2U1ZDM5MDYzNmY1Mjhi
|
10
|
+
MTY3YjlkNzEyZTliZWIyZTk1ZmRlODhhNTJlNjQxYjFmZTNkZTNmYzA3Mzdi
|
11
|
+
YjJmZGE4ODFmN2NhY2UyYWFlMWJmMzc0MTg2MDlkM2M1YjFjOWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmM3NWMwZGY3Y2I4NDA0NDgwODI0MjVmN2RjODRhNTdjNTMxNmMwYWEzYmY1
|
14
|
+
NmRjOTRjY2QyMGQyNWYwODE3NDk3Y2MzYjM1YjdmMTE3NDA1MWJjNmMwOTM0
|
15
|
+
MjBmMmJkMDc0Y2Q3NTA2YzM1M2IxNmIwYzgzMmY4ZmZiYzA1OTI=
|
data/README.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Rubybody
|
2
2
|
|
3
|
-
Rubybody provides calculations like TDEE, BMR and food calorie calculations
|
3
|
+
Rubybody provides calculations like Total Daily Energy Expenditure (TDEE), Basal metabolic rate (BMR) and food calorie calculations
|
4
|
+
|
5
|
+
Formulas:
|
6
|
+
|
7
|
+
BMR: Basal Metabolic Rate
|
8
|
+
TDEE: Total Daily Expenditure Estimate
|
9
|
+
|
10
|
+
Nutrition:
|
11
|
+
|
12
|
+
Protein: 4 calories per gram
|
13
|
+
Carb: 4 calories per gram
|
14
|
+
Fat: 9 calories per gram
|
15
|
+
Alcohol: 7 calories per gram
|
4
16
|
|
5
17
|
## Installation
|
6
18
|
|
@@ -19,6 +31,8 @@ Or install it yourself as:
|
|
19
31
|
## Usage
|
20
32
|
|
21
33
|
```ruby
|
34
|
+
# Height is in centimeters and weight is in kilograms
|
35
|
+
|
22
36
|
person = Rubybody::Person.new(81, 188, 25, :male)
|
23
37
|
person.bmr #=> 1816
|
24
38
|
person.tdee #=> 2180
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Rubybody
|
2
2
|
|
3
|
-
def self.bmr(
|
3
|
+
def self.bmr(weight_in_kg, height_in_cm, age, gender, method)
|
4
4
|
case method.to_sym
|
5
5
|
when :mifflin_st_jeor
|
6
|
-
Formulas::mifflin_st_jeor(
|
6
|
+
Formulas::mifflin_st_jeor(weight_in_kg, height_in_cm, age, gender)
|
7
7
|
when :harris_benedict
|
8
|
-
Formulas::harris_benedict(
|
8
|
+
Formulas::harris_benedict(weight_in_kg, height_in_cm, age, gender)
|
9
9
|
else
|
10
10
|
raise "ArgumentError"
|
11
11
|
end
|
data/lib/rubybody/formulas.rb
CHANGED
@@ -2,9 +2,9 @@ module Rubybody
|
|
2
2
|
|
3
3
|
module Formulas
|
4
4
|
|
5
|
-
def self.mifflin_st_jeor(
|
5
|
+
def self.mifflin_st_jeor(weight_in_kg, height_in_cm, age, gender)
|
6
6
|
|
7
|
-
base = 10*
|
7
|
+
base = 10*weight_in_kg + 6.25*height_in_cm - 5*age
|
8
8
|
|
9
9
|
case gender.to_sym
|
10
10
|
when :male
|
@@ -17,13 +17,13 @@ module Rubybody
|
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.harris_benedict(
|
20
|
+
def self.harris_benedict(weight_in_kg, height_in_cm, age, gender)
|
21
21
|
|
22
22
|
case gender.to_sym
|
23
23
|
when :male
|
24
|
-
return 66 + 6.23*(
|
24
|
+
return 66 + 6.23*(weight_in_kg * 2.20462) + 12.7*(height_in_cm * 0.393701) - 6.76 * age
|
25
25
|
when :female
|
26
|
-
return 655 + 4.35*(
|
26
|
+
return 655 + 4.35*(weight_in_kg * 2.20462) + 4.7*(height_in_cm * 0.393701) - 4.7 * age
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
data/lib/rubybody/nutrition.rb
CHANGED
@@ -7,18 +7,18 @@ module Rubybody
|
|
7
7
|
|
8
8
|
class Food
|
9
9
|
|
10
|
-
attr_accessor :
|
10
|
+
attr_accessor :protein_grams, :carb_grams, :fat_grams, :alcohol_grams
|
11
11
|
|
12
12
|
# All nutriments are expressed in grams
|
13
|
-
def initialize(
|
14
|
-
self.
|
15
|
-
self.
|
16
|
-
self.
|
17
|
-
self.
|
13
|
+
def initialize(protein_grams, carb_grams, fat_grams, alcohol_grams=0)
|
14
|
+
self.protein_grams = protein_grams
|
15
|
+
self.carb_grams = carb_grams
|
16
|
+
self.fat_grams = fat_grams
|
17
|
+
self.alcohol_grams = alcohol_grams
|
18
18
|
end
|
19
19
|
|
20
20
|
def calories
|
21
|
-
return self.
|
21
|
+
return self.protein_grams * PROTEIN_CALORIES + self.carb_grams * CARB_CALORIES + self.fat_grams * FAT_CALORIES + self.alcohol_grams * ALCOHOL_CALORIES
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
data/lib/rubybody/person.rb
CHANGED
@@ -2,12 +2,12 @@ module Rubybody
|
|
2
2
|
|
3
3
|
class Person
|
4
4
|
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :weight_in_kg, :height_in_cm, :age, :gender, :activity, :bodyfat, :waist
|
6
6
|
|
7
7
|
# All units are in the SI standard
|
8
|
-
def initialize(
|
9
|
-
self.
|
10
|
-
self.
|
8
|
+
def initialize(weight_in_kg, height_in_cm, age, gender, activity=:sedentary, bodyfat=0, waist=0)
|
9
|
+
self.weight_in_kg = weight_in_kg
|
10
|
+
self.height_in_cm = height_in_cm
|
11
11
|
self.age = age
|
12
12
|
self.gender = gender
|
13
13
|
self.activity = activity
|
@@ -16,7 +16,7 @@ module Rubybody
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def bmr(method=:mifflin_st_jeor)
|
19
|
-
Rubybody::bmr(
|
19
|
+
Rubybody::bmr(weight_in_kg, height_in_cm, age, gender, method)
|
20
20
|
end
|
21
21
|
|
22
22
|
def tdee
|
data/lib/rubybody/version.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.3
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,4 +119,3 @@ test_files:
|
|
119
119
|
- spec/nutrition_spec.rb
|
120
120
|
- spec/person_spec.rb
|
121
121
|
- spec/spec_helper.rb
|
122
|
-
has_rdoc:
|