Module: BMI::CommonRisk
Constant Summary collapse
- UPPER_LIMIT =
25
- LOWER_LIMIT =
18.5.to_r
Instance Method Summary collapse
- #normal? ⇒ Boolean
- #obese? ⇒ Boolean
- #overweight? ⇒ Boolean
- #prime ⇒ Fixnum
- #risk ⇒ Symbol
- #underweight? ⇒ Boolean
- #very_obese? ⇒ Boolean
Instance Method Details
#normal? ⇒ Boolean
26 27 28 |
# File 'lib/bmi/commonrisk.rb', line 26 def normal? (LOWER_LIMIT...UPPER_LIMIT).cover?(@index) end |
#obese? ⇒ Boolean
18 19 20 |
# File 'lib/bmi/commonrisk.rb', line 18 def obese? @index >= 30 end |
#overweight? ⇒ Boolean
22 23 24 |
# File 'lib/bmi/commonrisk.rb', line 22 def overweight? @index >= UPPER_LIMIT end |
#prime ⇒ Fixnum
35 36 37 |
# File 'lib/bmi/commonrisk.rb', line 35 def prime 100 - ((@index / UPPER_LIMIT) * 100) end |
#risk ⇒ Symbol
9 10 11 12 |
# File 'lib/bmi/commonrisk.rb', line 9 def risk _risks.find { |symbol| __send__(:"#{symbol}?") } || raise('must not happen') end |
#underweight? ⇒ Boolean
30 31 32 |
# File 'lib/bmi/commonrisk.rb', line 30 def underweight? @index < LOWER_LIMIT end |
#very_obese? ⇒ Boolean
14 15 16 |
# File 'lib/bmi/commonrisk.rb', line 14 def very_obese? @index >= 35 end |