Class: Book

Inherits:
Bibliography show all
Defined in:
lib/biblio/fichero.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Bibliography

#<=>, #==

Constructor Details

#initialize(title, &block) ⇒ Book

Returns a new instance of Book.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/biblio/fichero.rb', line 8

def initialize (title, &block)
    self.author = []
    self.title = title
    self.date = []
    self.editorial = []
    self.isbn10 = []
    self.edition = []
    self.series = []
    self.book = []
    
  if block_given?  
  if block.arity == 1
    yield self
  else
   instance_eval &block 
  end
  end
    
    
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



4
5
6
# File 'lib/biblio/fichero.rb', line 4

def author
  @author
end

#bookObject

Returns the value of attribute book.



4
5
6
# File 'lib/biblio/fichero.rb', line 4

def book
  @book
end

#dateObject

Returns the value of attribute date.



4
5
6
# File 'lib/biblio/fichero.rb', line 4

def date
  @date
end

#editionObject

Returns the value of attribute edition.



4
5
6
# File 'lib/biblio/fichero.rb', line 4

def edition
  @edition
end

#editorialObject

Returns the value of attribute editorial.



4
5
6
# File 'lib/biblio/fichero.rb', line 4

def editorial
  @editorial
end

#isbn10Object

Returns the value of attribute isbn10.



4
5
6
# File 'lib/biblio/fichero.rb', line 4

def isbn10
  @isbn10
end

#seriesObject

Returns the value of attribute series.



4
5
6
# File 'lib/biblio/fichero.rb', line 4

def series
  @series
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/biblio/fichero.rb', line 4

def title
  @title
end

Instance Method Details

#autor(text, options = {}) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/biblio/fichero.rb', line 30

def autor(text, options = {})
    autor= text
    autor << "#{options[:surname]}" if options[:surname]
autor << " #{options[:name]}" if options[:name]

    author << autor
end

#editor(text, options = {}) ⇒ Object



54
55
56
57
58
59
# File 'lib/biblio/fichero.rb', line 54

def editor(text, options = {})
editor = text
editor << " (#{options[:amount]})" if options[:amount]

editorial << editor
end

#fecha(text, options = {}) ⇒ Object



38
39
40
41
42
43
# File 'lib/biblio/fichero.rb', line 38

def fecha(text, options = {})
fecha = text
editor << " (#{options[:amount]})" if options[:amount]

date << fecha
end

#isbn(tipo, options = {}) ⇒ Object



61
62
63
64
65
66
# File 'lib/biblio/fichero.rb', line 61

def isbn(tipo, options = {})
isbn = tipo
isbn << " (#{options[:number]})" if options[:number]

isbn10 << isbn
end

#libro(text, options = {}) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/biblio/fichero.rb', line 45

def libro(text, options = {})
libro = text
libro << "#{options[:titulo]}" if options[:titulo]
libro << " (#{options[:edicion]})" if options[:edicion]
libro << " (#{options[:serie]})" if options[:serie]
book << libro
end

#to_sObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/biblio/fichero.rb', line 69

def to_s
   


formato = "\nLibro en Formato APA:\n"
output = formato  

author.each_with_index do |instruction, index|
output << "\t#{instruction}"
end
 date.each_with_index do | date, index |
output << "\n\t#{(date)}"
end


 book.each_with_index do | book, index |
output << "\n\t#{book}"
end

 editorial.each_with_index do | editorial, index |
 output << "\n\tLugar de publicacion: #{(editorial)}\n"
end

output
end