Class: BodyMassIndex
- Inherits:
-
Object
- Object
- BodyMassIndex
- Defined in:
- lib/body_mass_index.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#mass ⇒ Object
readonly
Returns the value of attribute mass.
Instance Method Summary collapse
- #calculate_index ⇒ Object
-
#initialize(height, mass) ⇒ BodyMassIndex
constructor
A new instance of BodyMassIndex.
Constructor Details
#initialize(height, mass) ⇒ BodyMassIndex
4 5 6 |
# File 'lib/body_mass_index.rb', line 4 def initialize(height, mass) @height, @mass = height, mass end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
2 3 4 |
# File 'lib/body_mass_index.rb', line 2 def height @height end |
#mass ⇒ Object (readonly)
Returns the value of attribute mass.
2 3 4 |
# File 'lib/body_mass_index.rb', line 2 def mass @mass end |
Instance Method Details
#calculate_index ⇒ Object
8 9 10 |
# File 'lib/body_mass_index.rb', line 8 def calculate_index (mass / (height ** 2)).round(2) end |