bmi_calculator 0.1.1 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/bmi_calculator.gemspec +1 -1
- data/lib/bmi_calculator.rb +49 -8
- data/lib/bmi_calculator/convert.rb +21 -0
- data/lib/bmi_calculator/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7eb86f75ac794ac87a02eaf420bb97eac0b8ad77
|
|
4
|
+
data.tar.gz: 55f90897ec35f513e6a7bd52914c87d9e7b643d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20a8d3a610de669733ef7a3aac412008798d5e70cdfb49e9cff969b53df86490b963a4b092d0d7d7464dab798645e095137026a4956e1b78db28a17933fe46ff
|
|
7
|
+
data.tar.gz: 9d35db958cd5c49c70eeb1a5ab3c6c5242b03eb65b99a5d8bcb0ab564d1697ca9997997f235ab92cdabfc15932314acd4d5f863f5c0a5c7374ff746c99690cca
|
data/README.md
CHANGED
|
@@ -34,6 +34,12 @@ bmi = BmiCalculator.calc_cm_g(170, 60000)
|
|
|
34
34
|
|
|
35
35
|
# calc feet, inch, pound
|
|
36
36
|
bmi = BmiCalculator.calc_yp(5, 7, 130)
|
|
37
|
+
|
|
38
|
+
# calc feet, pound
|
|
39
|
+
bmi = BmiCalculator.calc_feet_yp(5.5, 130)
|
|
40
|
+
|
|
41
|
+
# calc inch, pound
|
|
42
|
+
bmi = BmiCalculator.calc_inch_yp(67, 130)
|
|
37
43
|
```
|
|
38
44
|
|
|
39
45
|
## Development
|
|
@@ -44,7 +50,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
44
50
|
|
|
45
51
|
## Contributing
|
|
46
52
|
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/koyupi/bmi_calculator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
|
48
54
|
|
|
49
55
|
|
|
50
56
|
## License
|
data/bmi_calculator.gemspec
CHANGED
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
|
|
12
12
|
spec.summary = %q{Calculation BMI. height use m, cm, feet and inch.}
|
|
13
13
|
spec.description = %q{Calculation BMI. height use m, cm, feet and inch. You can very easy to use.}
|
|
14
|
-
spec.homepage = "https://github.com/
|
|
14
|
+
spec.homepage = "https://github.com/koyupi/bmi_calculator"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
data/lib/bmi_calculator.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
require "bmi_calculator/version"
|
|
2
|
+
require "bmi_calculator/convert"
|
|
2
3
|
|
|
3
4
|
module BmiCalculator
|
|
4
5
|
|
|
5
6
|
# calc bmi.
|
|
6
|
-
# @param [float] height(m)
|
|
7
|
-
# @param [float] weight(kg)
|
|
7
|
+
# @param [float] height height(m)
|
|
8
|
+
# @param [float] weight weight(kg)
|
|
8
9
|
# @param [intenger] round round number
|
|
9
10
|
# @return [float] bmi
|
|
10
11
|
def self.calc_m(height, weight, round=1)
|
|
@@ -14,8 +15,8 @@ module BmiCalculator
|
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
# calc bmi.
|
|
17
|
-
# @param [integer] height(cm)
|
|
18
|
-
# @param [float] weight(kg)
|
|
18
|
+
# @param [integer] height height(cm)
|
|
19
|
+
# @param [float] weight weight(kg)
|
|
19
20
|
# @param [integer] round round number
|
|
20
21
|
# @return [float] bmi
|
|
21
22
|
def self.calc_cm(height, weight, round=1)
|
|
@@ -27,8 +28,8 @@ module BmiCalculator
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
# calc bmi.
|
|
30
|
-
# @param [integer] height(cm)
|
|
31
|
-
# @param [float] weight(g)
|
|
31
|
+
# @param [integer] height height(cm)
|
|
32
|
+
# @param [float] weight weight(g)
|
|
32
33
|
# @param [integer] round round number
|
|
33
34
|
# @return [float] bmi
|
|
34
35
|
def self.calc_cm_g(height, weight, round=1)
|
|
@@ -43,15 +44,55 @@ module BmiCalculator
|
|
|
43
44
|
# calc bmi by yard-pound.
|
|
44
45
|
# @param [integer] height_ft height(feet)
|
|
45
46
|
# @param [integer] height_in height(inch)
|
|
46
|
-
# @param [float] weight(pound)
|
|
47
|
+
# @param [float] weight weight(pound)
|
|
47
48
|
# @param [integer] round round number
|
|
48
49
|
# @return [float] bmi
|
|
49
50
|
def self.calc_yp(height_ft, height_in, weight, round=1)
|
|
50
51
|
|
|
51
52
|
# 1feet = 12inch
|
|
52
53
|
height = ((height_ft * 12) + height_in) * 1.0
|
|
54
|
+
# calc bmi.
|
|
55
|
+
calc_inner_yp(height, weight, round)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# calc bmi by yard-pound.
|
|
59
|
+
# @param [integer] height height(feet)
|
|
60
|
+
# @param [float] weight weight(pound)
|
|
61
|
+
# @param [integer] round round number
|
|
62
|
+
# @return [float] bmi
|
|
63
|
+
def self.calc_feet_yp(height, weight, round=1)
|
|
64
|
+
|
|
65
|
+
# convert to inch.
|
|
66
|
+
height_in = BmiCalculator::Convert.feet_to_inch(height)
|
|
67
|
+
# calc bmi.
|
|
68
|
+
calc_inner_yp(height_in, weight, round)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# calc bmi by yard-pound.
|
|
72
|
+
# @param [integer] height height(inch)
|
|
73
|
+
# @param [float] weight weight(pound)
|
|
74
|
+
# @param [integer] round round number
|
|
75
|
+
# @return [float] bmi
|
|
76
|
+
def self.calc_inch_yp(height, weight, round=1)
|
|
77
|
+
|
|
78
|
+
# calc bmi.
|
|
79
|
+
calc_inner_yp(height * 1.0, weight, round)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
private
|
|
83
|
+
|
|
84
|
+
# yard-pound 703.0
|
|
85
|
+
YARD_POUND = 703.0
|
|
86
|
+
|
|
87
|
+
# calc bmi by yard-pound.
|
|
88
|
+
# @param [integer] height height(inch)
|
|
89
|
+
# @param [float] weight weight(pound)
|
|
90
|
+
# @param [integer] round round number
|
|
91
|
+
# @return [float] bmi
|
|
92
|
+
def self.calc_inner_yp(height, weight, round)
|
|
53
93
|
|
|
54
|
-
|
|
94
|
+
# calc bmi.
|
|
95
|
+
bmi = weight / (height * height) * YARD_POUND
|
|
55
96
|
bmi.round(round)
|
|
56
97
|
end
|
|
57
98
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
module BmiCalculator
|
|
3
|
+
|
|
4
|
+
# Convert class
|
|
5
|
+
class Convert
|
|
6
|
+
|
|
7
|
+
# convert feet to inch.
|
|
8
|
+
# @param [float] feet feet
|
|
9
|
+
# @return [float] inch
|
|
10
|
+
def self.feet_to_inch(feet)
|
|
11
|
+
feet * 12.0
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# convert inch to feet.
|
|
15
|
+
# @param [float] inch inch
|
|
16
|
+
# @return [float] feet
|
|
17
|
+
def self.inch_to_feet(inch)
|
|
18
|
+
inch / 12.0
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bmi_calculator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- h.shigemoto
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-09-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -72,8 +72,9 @@ files:
|
|
|
72
72
|
- bin/setup
|
|
73
73
|
- bmi_calculator.gemspec
|
|
74
74
|
- lib/bmi_calculator.rb
|
|
75
|
+
- lib/bmi_calculator/convert.rb
|
|
75
76
|
- lib/bmi_calculator/version.rb
|
|
76
|
-
homepage: https://github.com/
|
|
77
|
+
homepage: https://github.com/koyupi/bmi_calculator
|
|
77
78
|
licenses:
|
|
78
79
|
- MIT
|
|
79
80
|
metadata: {}
|
|
@@ -93,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
93
94
|
version: '0'
|
|
94
95
|
requirements: []
|
|
95
96
|
rubyforge_project:
|
|
96
|
-
rubygems_version: 2.6.
|
|
97
|
+
rubygems_version: 2.6.6
|
|
97
98
|
signing_key:
|
|
98
99
|
specification_version: 4
|
|
99
100
|
summary: Calculation BMI. height use m, cm, feet and inch.
|
|
100
101
|
test_files: []
|
|
101
|
-
has_rdoc:
|