Sha256: 667fb984ef81a0ccacc63f2fb7c76cf8123a92e15f19a9ff75454d126f6576dd

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

class Individuo

    attr_reader :nombre, :edad, :sexo

    include Comparable
    
    def initialize(nombre, edad, sexo)
        @nombre = nombre
        @edad = edad
        @sexo = sexo
    end
    
    def obtener_nombre
        @nombre
    end
    
    def obtener_edad
        @edad
    end
    
    def to_s
        cadena = ""
        sexo = ""
        cadena = cadena + "Nombre: #{@nombre}\n"
        cadena = cadena + "Edad: #{@edad}\n"
        if @sexo == 0
            sexo = "Hombre"
        else
            sexo = "Mujer"
        end
        cadena = cadena + "Sexo: #{sexo}\n"
        return cadena
    end
    
    def <=>(other)
        return nil unless other.instance_of? Individuo
        @edad <=> other.edad
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
etiqueta_nutricional-5.0.0 lib/etiqueta_nutricional/individuo.rb