Class: BodyMassIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/body_mass_index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#heightObject (readonly)

Returns the value of attribute height.



2
3
4
# File 'lib/body_mass_index.rb', line 2

def height
  @height
end

#massObject (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_indexObject



8
9
10
# File 'lib/body_mass_index.rb', line 8

def calculate_index
  (mass / (height ** 2)).round(2)
end