rubybody 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 049d4379776327bae375aba23f6d957e8420d69f
4
- data.tar.gz: a54f7b137f2be210e807a422416195d095dcc400
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTkwMjQ1ZWMzNmRhZTNlMDg1MDk1OTQwZGUzZTNhY2U0NTk0MDU0Yg==
5
+ data.tar.gz: !binary |-
6
+ ZDg2Nzc5MTFmZmY2OWUzYjI4YmRkZGQ0YTMyNzFiNjhmZjFjZjBkNQ==
5
7
  SHA512:
6
- metadata.gz: 09d76189c054a3ed1d0ee9405b89e7e370345274c9952a8e81ef93ee5f533643aff88f7e2c2eaa35675928c3ad9048430815816a12412b46aef9be4335700605
7
- data.tar.gz: 1d9dfdcc8d6a8d1295b8cf789179aac03c30c2bc70fa508ecf3551d2239ccd449723f193abd8865a066d3259802078dcc0b10af384f63dfe022eb1e9f46bfeb0
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
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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 Calculations
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::BMR::mifflin_st_jeor(height, weight, age, gender)
6
+ Formulas::mifflin_st_jeor(height, weight, age, gender)
7
7
  when :harris_benedict
8
- Formulas::BMR::harris_benedict(height, weight, age, gender)
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::TDEE::typical(bmr, activity_level)
15
+ Formulas::typical(bmr, activity_level)
16
16
  end
17
17
 
18
18
  end
@@ -1,6 +1,6 @@
1
- module Formulas
2
-
3
- module BMR
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
@@ -1,24 +1,28 @@
1
- class Person
1
+ module Rubybody
2
+
3
+ class Person
2
4
 
3
- attr_accessor :height, :weight, :age, :gender, :activity, :bodyfat, :waist
5
+ attr_accessor :height, :weight, :age, :gender, :activity, :bodyfat, :waist
4
6
 
5
- # All units are in the SI standard
6
- def initialize(height, weight, age, gender, activity=:sedentary, bodyfat=0, waist=0)
7
- self.height = height
8
- self.weight = weight
9
- self.age = age
10
- self.gender = gender
11
- self.activity = activity
12
- self.bodyfat = bodyfat
13
- self.waist = waist
14
- end
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
- def bmr(method=:mifflin_st_jeor)
17
- Calculations::bmr(height, weight, age, gender, method)
18
- end
18
+ def bmr(method=:mifflin_st_jeor)
19
+ Rubybody::bmr(height, weight, age, gender, method)
20
+ end
19
21
 
20
- def tdee
21
- Calculations::tdee(bmr, activity)
22
- end
22
+ def tdee
23
+ Rubybody::tdee(bmr, activity)
24
+ end
23
25
 
26
+ end
27
+
24
28
  end
@@ -1,3 +1,3 @@
1
1
  module Rubybody
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/rubybody.rb CHANGED
@@ -2,7 +2,7 @@ require "rubybody/version"
2
2
  require "rubybody/calculations"
3
3
  require "rubybody/formulas"
4
4
  require "rubybody/person"
5
- require 'ruby-units'
5
+ require "rubybody/nutrition"
6
6
 
7
7
  module Rubybody
8
8
 
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Formulas::BMR do
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::BMR::mifflin_st_jeor(weight, height, age, gender).to_i.should eql(1816)
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::BMR::mifflin_st_jeor(weight, height, age, gender).to_i.should eql(1650)
17
+ Rubybody::Formulas::mifflin_st_jeor(weight, height, age, gender).to_i.should eql(1650)
18
18
  end
19
19
  end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rubybody do
4
+ it "should return 150 calories" do
5
+ f = Rubybody::Food.new(10, 10, 10)
6
+ f.calories.should eql(170)
7
+ end
8
+ 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
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require 'rubybody'
4
+ require 'ruby-units'
4
5
 
5
6
  RSpec.configure do |config|
6
7
 
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.1
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-03 00:00:00.000000000 Z
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.0.3
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: