Class: Article
- Inherits:
-
Bibliography
- Object
- Bibliography
- Article
- Defined in:
- lib/biblio/article.rb
Instance Attribute Summary collapse
-
#magazine ⇒ Object
Returns the value of attribute magazine.
-
#newspaper ⇒ Object
Returns the value of attribute newspaper.
-
#pages ⇒ Object
Returns the value of attribute pages.
Attributes inherited from Bibliography
Instance Method Summary collapse
- #autor(text, options = {}) ⇒ Object
- #fecha(text, options = {}) ⇒ Object
-
#initialize(title, &block) ⇒ Article
constructor
A new instance of Article.
- #revista(text, options = {}) ⇒ Object
- #to_s ⇒ Object
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. = [] 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
#magazine ⇒ Object
Returns the value of attribute magazine.
3 4 5 |
# File 'lib/biblio/article.rb', line 3 def magazine @magazine end |
#newspaper ⇒ Object
Returns the value of attribute newspaper.
3 4 5 |
# File 'lib/biblio/article.rb', line 3 def newspaper @newspaper end |
#pages ⇒ Object
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, = {}) autor= text autor << "#{[:surname]}" if [:surname] autor << " #{[:name]}" if [:name] << autor end |
#fecha(text, options = {}) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/biblio/article.rb', line 31 def fecha(text, = {}) fecha = text fecha << "(#{[:amount]})" if [: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, = {}) revista = text revista << "#{[:titulo]}" if [:titulo] revista << " #{[:periodico]}" if [:periodico] revista << " #{[:paginas]}" if [:paginas] magazine << revista end |
#to_s ⇒ Object
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 .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 |