Class: IMC
- Inherits:
-
Object
- Object
- IMC
- Includes:
- Comparable
- Defined in:
- lib/NutrientesEdu/IMC.rb,
lib/NutrientesEdu/version.rb
Direct Known Subclasses
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#altura ⇒ Object
readonly
Returns the value of attribute altura.
-
#edad ⇒ Object
readonly
Returns the value of attribute edad.
-
#peso ⇒ Object
readonly
Returns the value of attribute peso.
-
#sexo ⇒ Object
readonly
Returns the value of attribute sexo.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #calcular_imc ⇒ Object
-
#initialize(a, b, c, d) ⇒ IMC
constructor
A new instance of IMC.
- #porcentaje_grasa ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(a, b, c, d) ⇒ IMC
Returns a new instance of IMC.
6 7 8 9 10 11 |
# File 'lib/NutrientesEdu/IMC.rb', line 6 def initialize(a,b,c,d) @peso=a @altura=b @edad=c @sexo=d end |
Instance Attribute Details
#altura ⇒ Object (readonly)
Returns the value of attribute altura.
4 5 6 |
# File 'lib/NutrientesEdu/IMC.rb', line 4 def altura @altura end |
#edad ⇒ Object (readonly)
Returns the value of attribute edad.
4 5 6 |
# File 'lib/NutrientesEdu/IMC.rb', line 4 def edad @edad end |
#peso ⇒ Object (readonly)
Returns the value of attribute peso.
4 5 6 |
# File 'lib/NutrientesEdu/IMC.rb', line 4 def peso @peso end |
#sexo ⇒ Object (readonly)
Returns the value of attribute sexo.
4 5 6 |
# File 'lib/NutrientesEdu/IMC.rb', line 4 def sexo @sexo end |
Instance Method Details
#<=>(other) ⇒ Object
25 26 27 |
# File 'lib/NutrientesEdu/IMC.rb', line 25 def <=> (other) calcular_imc <=> other.calcular_imc end |
#calcular_imc ⇒ Object
13 14 15 |
# File 'lib/NutrientesEdu/IMC.rb', line 13 def calcular_imc (@peso)/(@altura*@altura) end |
#porcentaje_grasa ⇒ Object
17 18 19 |
# File 'lib/NutrientesEdu/IMC.rb', line 17 def porcentaje_grasa ((1.2*calcular_imc)+(0.23*edad)-(10.8*sexo)-5.4) end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/NutrientesEdu/IMC.rb', line 21 def to_s "#{@peso} #{@altura} #{@edad} #{@sexo}" end |