Class: Referencia

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/refbiblio_alu0100505078/referencia.rb

Direct Known Subclasses

Art_periodico, Art_rev, Doc_electronico, Libro

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nombre, &block) ⇒ Referencia

constructor recibiendo un bloque del elemento bibliografico.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 17

def initialize(nombre,&block)
    self.nombre=nombre
    self.tipo_doc=[]
    self.autor=[]
    self.titulo=[]
    if block_given?  
        if block.arity == 1
            yield self
        else
            instance_eval &block 
        end
    end
end

Instance Attribute Details

#autorObject

Returns the value of attribute autor.



3
4
5
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 3

def autor
  @autor
end

#nombreObject

Returns the value of attribute nombre.



3
4
5
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 3

def nombre
  @nombre
end

#tipo_docObject

Returns the value of attribute tipo_doc.



3
4
5
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 3

def tipo_doc
  @tipo_doc
end

#tituloObject

Returns the value of attribute titulo.



3
4
5
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 3

def titulo
  @titulo
end

Instance Method Details

#<=>(other) ⇒ Object



31
32
33
34
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 31

def <=>(other)
    t_comparable=self.autor <=> other.autor
    t_comparable
end

#aut(options = {}) ⇒ Object

muestra la informacion del autor mediante los hash recibidos.



58
59
60
61
62
63
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 58

def aut(options ={})
    t_autor=""
    t_autor << "\t Apellidos: #{options[:apellido]}" if options[:apellido]
    t_autor << "\t Nombre: #{options[:nombre]}" if options[:nombre]
    autor << t_autor
end

#tipodoc(options = {}) ⇒ Object

muestra el tipo de documento mediante los hash recibidos



65
66
67
68
69
70
71
72
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 65

def tipodoc(options={})
  t_tipodoc=""
  t_tipodoc << "\t Nombre libro: #{options[:nombre]}" if options[:nombre]
  t_tipodoc << "\t Volumen: #{options[:volumen]}" if options[:volumen]
  t_tipodoc << "\t Edicion:#{options[:edicion]}" if options[:edicion]
  tipo_doc<< t_tipodoc
  #end
end

#tit(options = {}) ⇒ Object

muestra la informacion del titulo mediante los hash recibidos.



74
75
76
77
78
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 74

def tit(options={})
    t_titulo=""
    t_titulo << "#{options[:titulo]}" if options[:titulo]
    titulo << t_titulo
end

#to_sObject

metodo to_s para mostrar en forma de texto



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/refbiblio_alu0100505078/referencia.rb', line 36

def to_s
    output1 = nombre
    output1 << "\n#{'=' * nombre.size}\n"
    output1 << " Autor:\n"
    
    autor.reverse.each_with_index do |t_aut, index|
        output1 << " #{t_aut}\n"
    end
    output1 << " #{self.class.to_s}\n"
    tipo_doc.each_with_index do |t_tipodoc, index|
        output1 << " #{t_tipodoc}\n"
    end
    output1 << " Titulo:"
    titulo.each_with_index do |t_titulo, index|
        output1 << " #{t_titulo.capitalize}\n"
    end
    output1
    
end