class Referencia

Attributes

autores[RW]
editorial[RW]
fecha[RW]
isbn10[RW]
isbn13[RW]
nedicion[RW]
serie[RW]
titulo[RW]

Public Class Methods

new(&block) click to toggle source
# File lib/bibliogem/Referencia.rb, line 4
def initialize &block
        (block.arity<1 ? (instance_eval &block) : block.call(self)) if block_given?
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/bibliogem/Referencia.rb, line 27
def <=> other
        if(@autores == other.autores)
                if(@fecha == other.fecha)
                        if(@titulo == other.titulo)
                                return 0
                        else
                                aux=[@titulo, other.titulo]
                                aux.sort_by! do |t|
                                        t
                                end
                                if(aux.first == @titulo)
                                        return -1
                                end
                                return 1
                        end
                elsif(@fecha < other.fecha)
                        return -1
                else
                        return 1
                end
        else
                aux=[@autores, other.autores]
                aux.sort_by! do |t|
                        t
                end
                if(aux.first == @autores)
                        return -1
                end
                return 1
        end
end
comprobar() click to toggle source
# File lib/bibliogem/Referencia.rb, line 7
def comprobar
        if !aut.any?
                raise ArgumentError.new("Error: Se requiere al menos un autor")
        end
        if tit.nil?
                raise ArgumentError.new("Error: Se requiere un tiulo")
        end
        if edi.nil?
                raise ArgumentError.new("Error: Se requiere una editorial")
        end
        if ne.nil?
                raise ArgumentError.new("Error Se requiere un numero de edicion")
        end
        if fe.nil?
                raise ArgumentError.new("Error: Se requiere una fecha con formato %d-%m-%Y")
        end
        if is10.nil? && is13.nil?
                raise ArgumentError.new("Error: Se requiere al menos un codigo isbn")
        end
end
to_s() click to toggle source
# File lib/bibliogem/Referencia.rb, line 58
def to_s
        "#{@autores}, #{@titulo}, #{@serie}, #{@editorial}, #{@nedicion}, #{@fecha}, #{@isbn10}, #{@isbn13}"
end