Class: Individuo

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/nutricion/icc.rb

Overview

Clase Individuo (Individuo que tiene un nombre, edad y sexo)

Direct Known Subclasses

Paciente

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#edadObject (readonly)

Getters



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

def edad
  @edad
end

#nombreObject (readonly)

Getters



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

def nombre
  @nombre
end

#sexoObject (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_sObject

Mostrar los resultados



30
31
32
# File 'lib/nutricion/icc.rb', line 30

def to_s()
    "Sujeto: #{@nombre}. Edad: #{@edad}. Sexo: #{@sexo}. "
end