Class: HealthCalculator::BMI
- Inherits:
-
Object
- Object
- HealthCalculator::BMI
- Defined in:
- lib/health_calculator.rb
Overview
BMI Caluclator
Instance Method Summary collapse
-
#bmi_kg(weight_kg, height_mi) ⇒ Object
Calucalte BMI with weight in Kilos(KGS) and Height in Meters.
-
#bmi_lb(weight_lb, height_in) ⇒ Object
Calucalte BMI with weight in Pounds(LBS) and Height in Inches If Mass in Pounds(lbs).
-
#bmi_prime_kg(bmi_value) ⇒ Object
For instance, a person with BMI 34 has a BMI Prime of 34/25 = 1.36, BMI PRIME = BMIVALUE / 25.
-
#inch_to_feet_converter ⇒ Object
Convert height Inches into Feet.
-
#kilo_to_pound_converter(weight_kg) ⇒ Object
Kilo to Pound Converter.
-
#pound_to_kilo_converter(weight_lb) ⇒ Object
convert weight into kilos one pound = 0.4535 ( 1 lb = 453.59 gms) one kilo = 2.20462 lbs.
-
#rating_kg(bmi_value) ⇒ Object
RATING FOR BMI VALUE MASS (KILO) BASED.
-
#rating_lb(bmi_value) ⇒ Object
RATING FOR BMI VALUE POUND BASED.
Instance Method Details
#bmi_kg(weight_kg, height_mi) ⇒ Object
Calucalte BMI with weight in Kilos(KGS) and Height in Meters
30 31 32 33 34 |
# File 'lib/health_calculator.rb', line 30 def bmi_kg(weight_kg,height_mi) puts "Weight should be in Kilos and Height should be in meters" #puts "Weight = 10kgs ; height = 6 meters" @bmi_calac_kg = (weight_kg / (height_mi * height_mi)).round(2) end |
#bmi_lb(weight_lb, height_in) ⇒ Object
Calucalte BMI with weight in Pounds(LBS) and Height in Inches If Mass in Pounds(lbs)
38 39 40 41 42 43 |
# File 'lib/health_calculator.rb', line 38 def bmi_lb(weight_lb,height_in) puts "Weight should be in Pounds and Height in Inches " #puts "Weight = 10lbs ; height = 160 Inches , 1 Foot = 12 Inches" #@bmi_calac_lb = ( (weight_lb / (height_in * height_in)).round(2) ) * 703 @bmi_calac_lb = ( (weight_lb) / (height_in * height_in).round(2) ) * 703.06957964 end |
#bmi_prime_kg(bmi_value) ⇒ Object
For instance, a person with BMI 34 has a BMI Prime of 34/25 = 1.36, BMI PRIME = BMIVALUE / 25
48 49 50 51 52 |
# File 'lib/health_calculator.rb', line 48 def bmi_prime_kg(bmi_value) if bmi_value > 25 @bmi_prime_kg = bmi_value / 25 end end |
#inch_to_feet_converter ⇒ Object
Convert height Inches into Feet
24 25 26 |
# File 'lib/health_calculator.rb', line 24 def inch_to_feet_converter end |
#kilo_to_pound_converter(weight_kg) ⇒ Object
Kilo to Pound Converter
17 18 19 20 |
# File 'lib/health_calculator.rb', line 17 def kilo_to_pound_converter(weight_kg) puts "#{weight_kg} Kilos" @weight_lb = ( (weight_kg) * (0.453592) ).to_f + "\s Pounds" end |
#pound_to_kilo_converter(weight_lb) ⇒ Object
convert weight into kilos one pound = 0.4535 ( 1 lb = 453.59 gms) one kilo = 2.20462 lbs
11 12 13 14 |
# File 'lib/health_calculator.rb', line 11 def pound_to_kilo_converter(weight_lb) @weight_kg = ( weight_lb * (0.453592) ) #one pound = 0.453592 kilos print @weight_kg end |
#rating_kg(bmi_value) ⇒ Object
RATING FOR BMI VALUE MASS (KILO) BASED
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/health_calculator.rb', line 84 def (bmi_value) result = case bmi_value when 0..15 then "Very severely underweight less than 0.60" when 15..16 then "Severely underweight from 0.60 to 0.64" when 16..18.5 then "Underweight from 0.64 to 0.74" when 18.5..25 then "Normal (healthy weight) from 0.74 to 1.0" when 25..30 then "Overweight from 1.0 to 1.2" when 30..35 then " Obese Class I (Moderately obese) from 1.2 to 1.4" when 35..40 then "Obese Class II (Severely obese) from 1.4 to 1.6" when 40..100 then "Obese Class III (Very severely obese) over 1.6" else "Invalid Score" end end |
#rating_lb(bmi_value) ⇒ Object
RATING FOR BMI VALUE POUND BASED
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/health_calculator.rb', line 68 def (bmi_value) result = case bmi_value when 0..15 then "Very severely underweight less than 15" when 15..16 then "Severely underweight from 15.0 to 16.0" when 16..18.5 then "Underweight from 16.0 to 18.5" when 18.5..25 then "Normal (healthy weight) from 18.25 to 25" when 25..30 then "Overweight from 25 to 30" when 30..35 then " Obese Class I (Moderately obese) from 30 to 35" when 35..40 then "Obese Class II (Severely obese) from 35 to 40" when 40..100 then "Obese Class III (Very severely obese) over 40" else "Invalid Score" end end |