Class: Article

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

Instance Attribute Summary collapse

Attributes inherited from Bibliography

#author, #date, #title

Instance Method Summary collapse

Methods inherited from Bibliography

#<=>, #==

Constructor Details

#initialize(title, &block) ⇒ Article

Returns a new instance of Article.



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

def initialize(title, &block)
    
    self.author = []
    self.title = []
    self.date = []
    self.newspaper = []
    self.pages = []
    self.magazine = []
    
    if block_given?  
    if block.arity == 1
    yield self
    else
    instance_eval &block 
    end
    end
end

Instance Attribute Details

#magazineObject

Returns the value of attribute magazine.



3
4
5
# File 'lib/biblio/article.rb', line 3

def magazine
  @magazine
end

#newspaperObject

Returns the value of attribute newspaper.



3
4
5
# File 'lib/biblio/article.rb', line 3

def newspaper
  @newspaper
end

#pagesObject

Returns the value of attribute pages.



3
4
5
# File 'lib/biblio/article.rb', line 3

def pages
  @pages
end

Instance Method Details

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



23
24
25
26
27
28
29
# File 'lib/biblio/article.rb', line 23

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

author << autor
end

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



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

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

date << fecha
end

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



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

def revista(text, options = {})
revista = text
revista << "#{options[:titulo]}" if options[:titulo]
revista << " #{options[:periodico]}" if options[:periodico]
revista << " #{options[:paginas]}" if options[:paginas]
magazine << revista
end

#to_sObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/biblio/article.rb', line 47

def to_s
   


formato = "\nRevista 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

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

output

end