health_stats 0.0.3 → 0.1.0
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.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/health_stats.gemspec +9 -7
- data/lib/health_stats/age.rb +9 -5
- data/lib/health_stats/bmi.rb +2 -25
- data/lib/health_stats/cdc_data/bmi.rb +444 -446
- data/lib/health_stats/cdc_data/height.rb +493 -0
- data/lib/health_stats/cdc_data/weight.rb +494 -0
- data/lib/health_stats/cdc_data.rb +8 -5
- data/lib/health_stats/percentile.rb +42 -0
- data/lib/health_stats.rb +5 -3
- data/spec/spec_health_stats.rb +24 -8
- metadata +26 -11
- data/pkg/health_stats-0.0.1.gem +0 -0
- data/pkg/health_stats-0.0.2.gem +0 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
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
|
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{
|
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
|
-
"
|
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.
|
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::
|
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"])
|
data/lib/health_stats/age.rb
CHANGED
@@ -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
|
9
|
-
|
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 +=
|
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
|
data/lib/health_stats/bmi.rb
CHANGED
@@ -1,33 +1,10 @@
|
|
1
|
-
module HealthStats
|
2
|
-
|
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
|