Class: Individuo
- Inherits:
-
Object
- Object
- Individuo
- Includes:
- Comparable
- Defined in:
- lib/InforNutricional/icc.rb
Overview
Clase que representa los datos básicos de un Individuo
Direct Known Subclasses
Instance Attribute Summary collapse
-
#edad ⇒ Object
readonly
Returns the value of attribute edad.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
-
#sexo ⇒ Object
readonly
Returns the value of attribute sexo.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Método comparable.
-
#initialize(nombre, edad, sexo) ⇒ Individuo
constructor
Método para inicializar y hacer new.
-
#to_s ⇒ Object
Método para mostrar los resultados.
Constructor Details
#initialize(nombre, edad, sexo) ⇒ Individuo
Método para inicializar y hacer new
8 9 10 11 12 13 14 |
# File 'lib/InforNutricional/icc.rb', line 8 def initialize(nombre, edad, sexo) #Variables de instancia @nombre = nombre @edad = edad @sexo = sexo end |
Instance Attribute Details
#edad ⇒ Object (readonly)
Returns the value of attribute edad.
4 5 6 |
# File 'lib/InforNutricional/icc.rb', line 4 def edad @edad end |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
4 5 6 |
# File 'lib/InforNutricional/icc.rb', line 4 def nombre @nombre end |
#sexo ⇒ Object (readonly)
Returns the value of attribute sexo.
4 5 6 |
# File 'lib/InforNutricional/icc.rb', line 4 def sexo @sexo end |
Instance Method Details
#<=>(other) ⇒ Object
Método comparable
21 22 23 24 25 26 |
# File 'lib/InforNutricional/icc.rb', line 21 def <=>(other) # Método comparable return nil unless other.instance_of?Individuo @nombre <=> other.nombre @edad <=> other.edad @sexo <=> other.sexo end |
#to_s ⇒ Object
Método para mostrar los resultados.
16 17 18 |
# File 'lib/InforNutricional/icc.rb', line 16 def to_s() #Método para mostrar los resultados. "Datos del individuo: #{@nombre}. Edad: #{@edad}. Sexo: #{@sexo}. " end |