Class: Biblio

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/bibliografia/biblio.rb

Direct Known Subclasses

Articulo, ArticuloPeriodico, Electronico, Libro

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(titulo, &block) ⇒ Biblio

Returns a new instance of Biblio.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bibliografia/biblio.rb', line 7

def initialize(titulo, &block)

     self.titulo = titulo
     self.autor = []
     self.fecha = []

     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.



5
6
7
# File 'lib/bibliografia/biblio.rb', line 5

def autor
  @autor
end

#fechaObject

Returns the value of attribute fecha.



5
6
7
# File 'lib/bibliografia/biblio.rb', line 5

def fecha
  @fecha
end

#tituloObject

Returns the value of attribute titulo.



5
6
7
# File 'lib/bibliografia/biblio.rb', line 5

def titulo
  @titulo
end

Instance Method Details

#<=>(anOther) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bibliografia/biblio.rb', line 33

def <=>(anOther)
     if((@autor <=> anOther.autor) == 0)
          if((@fecha <=> anOther.fecha)==0)
               
               @titulo <=> anOther.titulo
           
          else
               @fecha <=> anOther.fecha
          end
     else
          @autor <=> anOther.autor
     end
end

#author(name, options = {}) ⇒ Object



28
29
30
31
# File 'lib/bibliografia/biblio.rb', line 28

def author(name, options = {})
     author = name
     autor << author
end

#date(name, options = {}) ⇒ Object



22
23
24
25
26
# File 'lib/bibliografia/biblio.rb', line 22

def date(name, options = {})
     date = name
     
     fecha << date
end

#to_sObject



48
49
50
# File 'lib/bibliografia/biblio.rb', line 48

def to_s()

end