health_stats 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.1.0
data/health_stats.gemspec CHANGED
@@ -5,18 +5,19 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{health_stats}
8
- s.version = "0.0.3"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Martin"]
12
- s.date = %q{2009-12-03}
12
+ s.date = %q{2010-06-22}
13
13
  s.email = %q{assplecake@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
16
16
  "README.md"
17
17
  ]
18
18
  s.files = [
19
- "LICENSE",
19
+ ".gitignore",
20
+ "LICENSE",
20
21
  "README.md",
21
22
  "Rakefile",
22
23
  "VERSION",
@@ -26,15 +27,16 @@ Gem::Specification.new do |s|
26
27
  "lib/health_stats/bmi.rb",
27
28
  "lib/health_stats/cdc_data.rb",
28
29
  "lib/health_stats/cdc_data/bmi.rb",
30
+ "lib/health_stats/cdc_data/height.rb",
31
+ "lib/health_stats/cdc_data/weight.rb",
32
+ "lib/health_stats/percentile.rb",
29
33
  "lib/health_stats/statistics.rb",
30
- "pkg/health_stats-0.0.1.gem",
31
- "pkg/health_stats-0.0.2.gem",
32
34
  "spec/spec_health_stats.rb"
33
35
  ]
34
36
  s.homepage = %q{http://github.com/assplecake/healthdata}
35
37
  s.rdoc_options = ["--charset=UTF-8"]
36
38
  s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.5}
39
+ s.rubygems_version = %q{1.3.7}
38
40
  s.summary = %q{Convenience methods for age, bmi, bmi percentile}
39
41
  s.test_files = [
40
42
  "spec/spec_health_stats.rb"
@@ -44,7 +46,7 @@ Gem::Specification.new do |s|
44
46
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
47
  s.specification_version = 3
46
48
 
47
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
50
  s.add_development_dependency(%q<activesupport>, [">= 2.3"])
49
51
  else
50
52
  s.add_dependency(%q<activesupport>, [">= 2.3"])
@@ -4,15 +4,19 @@ module HealthStats
4
4
  return if dob.nil?
5
5
  today = Date.today
6
6
  months = age_in_years * 12
7
-
8
- if today.month > dob.month
9
- months += (today.month - dob.month)
7
+
8
+ if today.month >= dob.month
9
+ if today.month == dob.month && today.day < dob.day
10
+ months += 12
11
+ else
12
+ months += (today.month - dob.month)
13
+ end
10
14
  else
11
- months += today.month
15
+ months += (today.month + 12) - dob.month
12
16
  end
13
17
 
14
18
  if today.day >= dob.day
15
- months += 1 + (today.day - dob.day > 15 ? 0.5 : 0.0)
19
+ months += (today.day - dob.day > 15 ? 0.5 : 0.0)
16
20
  else
17
21
  months += (today.day - dob.day + 30) > 15 ? -0.5 : -1.0
18
22
  end
@@ -1,33 +1,10 @@
1
- module HealthStats
2
- autoload :CDCData, File.dirname(__FILE__) + '/cdc_data'
3
-
4
- module BMI
5
- include Statistics
6
-
1
+ module HealthStats
2
+ module BMI
7
3
  def bmi
8
4
  if weight && height
9
5
  (((weight * 703) * 100) / (height ** 2)) / 100.0
10
6
  end
11
7
  end
12
-
13
- def bmi_percentile
14
- bmi_score = bmi
15
- month_age = age_in_months
16
- lms_value = nil
17
-
18
- return unless bmi_score && month_age && gender
19
- return if month_age < 24.0 || month_age > 241.0
20
-
21
- chart = gender == 'f' ? CDCData::BMI::Female : CDCData::BMI::Male
22
-
23
- while lms_value.nil?
24
- lms_value = chart[month_age]
25
- month_age -= 0.5
26
- end
27
-
28
- # I feel dirty.
29
- ((poz(lms(bmi_score, *lms_value)) * 1000000).to_i / 100.0).round / 100.0
30
- end
31
8
  end
32
9
 
33
10
  include BMI