Class: Individuo

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/tdd/valor_nutricional.rb

Direct Known Subclasses

Paciente

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nombre, apellido) ⇒ Individuo

Returns a new instance of Individuo.



5
6
7
8
# File 'lib/tdd/valor_nutricional.rb', line 5

def initialize(nombre,apellido)
    @nombre = nombre
    @apellido = apellido
end

Instance Attribute Details

#apellidoObject (readonly)

Returns the value of attribute apellido.



3
4
5
# File 'lib/tdd/valor_nutricional.rb', line 3

def apellido
  @apellido
end

#nombreObject (readonly)

Returns the value of attribute nombre.



3
4
5
# File 'lib/tdd/valor_nutricional.rb', line 3

def nombre
  @nombre
end

Instance Method Details

#<=>(other) ⇒ Object



14
15
16
17
# File 'lib/tdd/valor_nutricional.rb', line 14

def <=>(other)
   return nil unless other.instance_of?Individuo
   @nombre <=> other.nombre
end

#to_sObject



10
11
12
# File 'lib/tdd/valor_nutricional.rb', line 10

def to_s 
    "#{@nombre} #{@apellido}"
end