Class: Biblio
- Inherits:
-
Object
- Object
- Biblio
- Includes:
- Comparable
- Defined in:
- lib/biblioalu0100815146/biblio.rb
Instance Attribute Summary collapse
-
#autor ⇒ Object
Returns the value of attribute autor.
-
#fecha ⇒ Object
Returns the value of attribute fecha.
-
#titulo ⇒ Object
Returns the value of attribute titulo.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #author(name, options = {}) ⇒ Object
- #date(name, options = {}) ⇒ Object
-
#initialize(titulo, &block) ⇒ Biblio
constructor
A new instance of Biblio.
- #to_s ⇒ Object
Constructor Details
#initialize(titulo, &block) ⇒ Biblio
Returns a new instance of Biblio.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/biblioalu0100815146/biblio.rb', line 6 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
#autor ⇒ Object
Returns the value of attribute autor.
4 5 6 |
# File 'lib/biblioalu0100815146/biblio.rb', line 4 def autor @autor end |
#fecha ⇒ Object
Returns the value of attribute fecha.
4 5 6 |
# File 'lib/biblioalu0100815146/biblio.rb', line 4 def fecha @fecha end |
#titulo ⇒ Object
Returns the value of attribute titulo.
4 5 6 |
# File 'lib/biblioalu0100815146/biblio.rb', line 4 def titulo @titulo end |
Instance Method Details
#<=>(other) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/biblioalu0100815146/biblio.rb', line 33 def <=>(other) if(@autor != other.autor) @autor <=> other.autor elsif(@autor == other.autor) @fecha <=> other.fecha elsif(@fecha == other.fecha && @autor == other.autor) @titulo <=> other.titulo end end |
#author(name, options = {}) ⇒ Object
27 28 29 30 31 |
# File 'lib/biblioalu0100815146/biblio.rb', line 27 def (name, = {}) = name << " (#{[:amount]})" if [:amount] autor << end |
#date(name, options = {}) ⇒ Object
21 22 23 24 25 |
# File 'lib/biblioalu0100815146/biblio.rb', line 21 def date(name, = {}) date = name fecha << date end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/biblioalu0100815146/biblio.rb', line 45 def to_s() @salida = " AUTOR/ES: " + "#{@autor}" + " TITULO: " + "#{@titulo}" + " FECHA: " + "#{@fecha}" end |