Class: Nutri::Persona
- Inherits:
-
Object
- Object
- Nutri::Persona
- Includes:
- Comparable
- Defined in:
- lib/nutri/persona.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#apellido ⇒ Object
getters y setters.
-
#edad ⇒ Object
getters y setters.
-
#nombre ⇒ Object
getters y setters.
-
#sexo ⇒ Object
getters y setters.
Instance Method Summary collapse
-
#<=>(other) ⇒ bool
Compara los objetos sobre su edad.
-
#apellido_to_s ⇒ char
[surname to string].
-
#edad_to_s ⇒ char
[age to string].
-
#formato_to_s ⇒ char
Devuelve el string representado por el objeto como un char.
-
#initialize(nombre, apellido, edad, sexo) ⇒ nil
constructor
Initialize.
-
#nombre_to_s ⇒ char
[name to string].
-
#sexo_to_s ⇒ char
[sex to string].
Constructor Details
#initialize(nombre, apellido, edad, sexo) ⇒ nil
Initialize
23 24 25 |
# File 'lib/nutri/persona.rb', line 23 def initialize(nombre, apellido, edad, sexo) @nombre, @apellido, @edad, @sexo = nombre, apellido, edad, sexo end |
Instance Attribute Details
#apellido ⇒ Object
getters y setters
11 12 13 |
# File 'lib/nutri/persona.rb', line 11 def apellido @apellido end |
#edad ⇒ Object
getters y setters
11 12 13 |
# File 'lib/nutri/persona.rb', line 11 def edad @edad end |
#nombre ⇒ Object
getters y setters
11 12 13 |
# File 'lib/nutri/persona.rb', line 11 def nombre @nombre end |
#sexo ⇒ Object
getters y setters
11 12 13 |
# File 'lib/nutri/persona.rb', line 11 def sexo @sexo end |
Instance Method Details
#<=>(other) ⇒ bool
Compara los objetos sobre su edad
64 65 66 67 68 69 70 |
# File 'lib/nutri/persona.rb', line 64 def <=>(other) if other.is_a? Persona @edad <=> other.edad else false end end |
#apellido_to_s ⇒ char
- surname to string
39 40 41 |
# File 'lib/nutri/persona.rb', line 39 def apellido_to_s "Apellido: #{@apellido}\n" end |
#edad_to_s ⇒ char
- age to string
47 48 49 |
# File 'lib/nutri/persona.rb', line 47 def edad_to_s "Edad: #{@edad}\n" end |
#formato_to_s ⇒ char
Devuelve el string representado por el objeto como un char
76 77 78 |
# File 'lib/nutri/persona.rb', line 76 def formato_to_s puts "Nombre: #{@nombre}, Apellido: #{@apellido}, Edad: #{@edad}, Sexo: #{@sexo}" end |
#nombre_to_s ⇒ char
- name to string
31 32 33 |
# File 'lib/nutri/persona.rb', line 31 def nombre_to_s "Nombre: #{@nombre}\n" end |
#sexo_to_s ⇒ char
- sex to string
55 56 57 |
# File 'lib/nutri/persona.rb', line 55 def sexo_to_s "Sexo: #{@sexo}\n" end |