Class: Articulo

Inherits:
Biblio show all
Defined in:
lib/biblioalu0100815146/biblio.rb

Instance Attribute Summary collapse

Attributes inherited from Biblio

#autor, #fecha, #titulo

Instance Method Summary collapse

Methods inherited from Biblio

#<=>

Constructor Details

#initialize(titulo, &block) ⇒ Articulo

Returns a new instance of Articulo.



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/biblioalu0100815146/biblio.rb', line 119

def initialize(titulo,&block)

     self.titulo = titulo
     self.autor = []
     self.fecha = []   
     self.editor = []
     self.paginas = []
     self.obra = []
     
     if block_given?  
          if block.arity == 1
               yield self
          else
               instance_eval &block 
          end
     end
     
end

Instance Attribute Details

#editorObject

Returns the value of attribute editor.



118
119
120
# File 'lib/biblioalu0100815146/biblio.rb', line 118

def editor
  @editor
end

#obraObject

Returns the value of attribute obra.



118
119
120
# File 'lib/biblioalu0100815146/biblio.rb', line 118

def obra
  @obra
end

#paginasObject

Returns the value of attribute paginas.



118
119
120
# File 'lib/biblioalu0100815146/biblio.rb', line 118

def paginas
  @paginas
end

Instance Method Details

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



143
144
145
146
147
# File 'lib/biblioalu0100815146/biblio.rb', line 143

def author(name, options = {})
     author = name
     author << " (#{options[:amount]})" if options[:amount]
     autor << author
end

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



138
139
140
141
# File 'lib/biblioalu0100815146/biblio.rb', line 138

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

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



149
150
151
152
# File 'lib/biblioalu0100815146/biblio.rb', line 149

def edit(name, options = {})
     edit = name
     editor << edit
end

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



157
158
159
160
# File 'lib/biblioalu0100815146/biblio.rb', line 157

def obr(name, options = {})
     obr = name
     obra << obr
end

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



153
154
155
156
# File 'lib/biblioalu0100815146/biblio.rb', line 153

def pag(name, options = {})
     pag = name
     paginas << pag
end

#to_sObject



162
163
164
165
166
167
168
169
170
171
172
# File 'lib/biblioalu0100815146/biblio.rb', line 162

def to_s()
     
     output = titulo
     output << " #{autor.join(', ')} "
     output << "(#{fecha.join(', ')}) "
     output << "(#{editor.join(', ')}) "
     output << "(#{paginas.join(', ')}) "
     output << "#{obra.join(', ')} "

     output
end