Class: Individuo
Overview
Clase Individuo (Individuo que tiene un nombre, edad y sexo)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#edad ⇒ Object
readonly
Getters.
-
#nombre ⇒ Object
readonly
Getters.
-
#sexo ⇒ Object
readonly
Getters.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Metodo para que la clase sea Comparable.
-
#initialize(nombre, edad, sexo) ⇒ Individuo
constructor
Inicializar los valores.
-
#to_s ⇒ Object
Mostrar los resultados.
Constructor Details
#initialize(nombre, edad, sexo) ⇒ Individuo
Inicializar los valores
11 12 13 14 15 16 17 |
# File 'lib/nutricion/icc.rb', line 11 def initialize(nombre, edad, sexo) @nombre = nombre @edad = edad @sexo = sexo end |
Instance Attribute Details
#edad ⇒ Object (readonly)
Getters
8 9 10 |
# File 'lib/nutricion/icc.rb', line 8 def edad @edad end |
#nombre ⇒ Object (readonly)
Getters
8 9 10 |
# File 'lib/nutricion/icc.rb', line 8 def nombre @nombre end |
#sexo ⇒ Object (readonly)
Getters
8 9 10 |
# File 'lib/nutricion/icc.rb', line 8 def sexo @sexo end |
Instance Method Details
#<=>(other) ⇒ Object
Metodo para que la clase sea Comparable
20 21 22 23 24 25 26 27 |
# File 'lib/nutricion/icc.rb', line 20 def <=>(other) return nil unless other.instance_of?Individuo @nombre <=> other.nombre @edad <=> other.edad @sexo <=> other.sexo end |
#to_s ⇒ Object
Mostrar los resultados
30 31 32 |
# File 'lib/nutricion/icc.rb', line 30 def to_s() "Sujeto: #{@nombre}. Edad: #{@edad}. Sexo: #{@sexo}. " end |