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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTkwMjQ1ZWMzNmRhZTNlMDg1MDk1OTQwZGUzZTNhY2U0NTk0MDU0Yg==
4
+ M2ZhOTdiNjUzZTMxZWRjYTkwZjM5MzEwNDVhNjdhMTQ2NThjMzZiZQ==
5
5
  data.tar.gz: !binary |-
6
- ZDg2Nzc5MTFmZmY2OWUzYjI4YmRkZGQ0YTMyNzFiNjhmZjFjZjBkNQ==
6
+ MWI3NmUxMGE1OWNiNTBiZTI4MWUzNjA3MDAwODEwY2YyMTA0ZTAxNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWI5NWUwZjkxZDk2YWRmNWUzOGM3ZmU2ZTliOTY4MTkzZWQ0N2NlMmVjN2Qz
10
- N2FjMzE1OGE4NDI5MzRjMzExYjcwMWI4MzBhMWU1YjBjODE4YTUzM2VlODg0
11
- NGQ2YjBiZDBjMDNkN2YzMjk3MDBiMzk3YzU2ZGQzZTVmMmI3ZTE=
9
+ ZmZmOTViNDZlMDAxZDI0NjczOGJhNWFiODM1NzgxN2U1ZDM5MDYzNmY1Mjhi
10
+ MTY3YjlkNzEyZTliZWIyZTk1ZmRlODhhNTJlNjQxYjFmZTNkZTNmYzA3Mzdi
11
+ YjJmZGE4ODFmN2NhY2UyYWFlMWJmMzc0MTg2MDlkM2M1YjFjOWU=
12
12
  data.tar.gz: !binary |-
13
- NjVmMjA0NjQwZDE0ZDI3N2JiNDQyN2NlYTdjOTY3MzU5MzI2MjBkZjU1ZjIy
14
- YTM3NGZkOTUzODY3OWJkOGQ2ZDc5NmM1Zjk5MDQyODAxY2ZiYWY2ZTFkMGJj
15
- MzNhYTFlODZkYjM1NWI1NTg5ZTI1MjJjY2Q5ZDIzY2M2NjE2OGM=
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(height, weight, age, gender, method)
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(height, weight, age, gender)
6
+ Formulas::mifflin_st_jeor(weight_in_kg, height_in_cm, age, gender)
7
7
  when :harris_benedict
8
- Formulas::harris_benedict(height, weight, age, gender)
8
+ Formulas::harris_benedict(weight_in_kg, height_in_cm, age, gender)
9
9
  else
10
10
  raise "ArgumentError"
11
11
  end
@@ -2,9 +2,9 @@ module Rubybody
2
2
 
3
3
  module Formulas
4
4
 
5
- def self.mifflin_st_jeor(weight, height, age, gender)
5
+ def self.mifflin_st_jeor(weight_in_kg, height_in_cm, age, gender)
6
6
 
7
- base = 10*weight + 6.25*height - 5*age
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(weight, height, age, gender)
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*(weight * 2.20462) + 12.7*(height * 0.393701) - 6.76 * age
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*(weight * 2.20462) + 4.7*(height * 0.393701) - 4.7 * age
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
@@ -7,18 +7,18 @@ module Rubybody
7
7
 
8
8
  class Food
9
9
 
10
- attr_accessor :protein, :carb, :fat, :alcohol
10
+ attr_accessor :protein_grams, :carb_grams, :fat_grams, :alcohol_grams
11
11
 
12
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
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.protein * PROTEIN_CALORIES + self.carb * CARB_CALORIES + self.fat * FAT_CALORIES + self.alcohol * ALCOHOL_CALORIES
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
@@ -2,12 +2,12 @@ module Rubybody
2
2
 
3
3
  class Person
4
4
 
5
- attr_accessor :height, :weight, :age, :gender, :activity, :bodyfat, :waist
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(height, weight, age, gender, activity=:sedentary, bodyfat=0, waist=0)
9
- self.height = height
10
- self.weight = weight
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(height, weight, age, gender, method)
19
+ Rubybody::bmr(weight_in_kg, height_in_cm, age, gender, method)
20
20
  end
21
21
 
22
22
  def tdee
@@ -1,3 +1,3 @@
1
1
  module Rubybody
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-04 00:00:00.000000000 Z
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: