Class: Referencia
- Inherits:
-
Object
- Object
- Referencia
- Includes:
- Comparable
- Defined in:
- lib/bibliogem/Referencia.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#autores ⇒ Object
Returns the value of attribute autores.
-
#editorial ⇒ Object
Returns the value of attribute editorial.
-
#fecha ⇒ Object
Returns the value of attribute fecha.
-
#isbn10 ⇒ Object
Returns the value of attribute isbn10.
-
#isbn13 ⇒ Object
Returns the value of attribute isbn13.
-
#nedicion ⇒ Object
Returns the value of attribute nedicion.
-
#serie ⇒ Object
Returns the value of attribute serie.
-
#titulo ⇒ Object
Returns the value of attribute titulo.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #comprobar ⇒ Object
-
#initialize(&block) ⇒ Referencia
constructor
A new instance of Referencia.
- #to_s ⇒ Object
Constructor Details
#initialize(&block) ⇒ Referencia
Returns a new instance of Referencia.
4 5 6 |
# File 'lib/bibliogem/Referencia.rb', line 4 def initialize &block (block.arity<1 ? (instance_eval &block) : block.call(self)) if block_given? end |
Instance Attribute Details
#autores ⇒ Object
Returns the value of attribute autores.
3 4 5 |
# File 'lib/bibliogem/Referencia.rb', line 3 def autores @autores end |
#editorial ⇒ Object
Returns the value of attribute editorial.
3 4 5 |
# File 'lib/bibliogem/Referencia.rb', line 3 def editorial @editorial end |
#fecha ⇒ Object
Returns the value of attribute fecha.
3 4 5 |
# File 'lib/bibliogem/Referencia.rb', line 3 def fecha @fecha end |
#isbn10 ⇒ Object
Returns the value of attribute isbn10.
3 4 5 |
# File 'lib/bibliogem/Referencia.rb', line 3 def isbn10 @isbn10 end |
#isbn13 ⇒ Object
Returns the value of attribute isbn13.
3 4 5 |
# File 'lib/bibliogem/Referencia.rb', line 3 def isbn13 @isbn13 end |
#nedicion ⇒ Object
Returns the value of attribute nedicion.
3 4 5 |
# File 'lib/bibliogem/Referencia.rb', line 3 def nedicion @nedicion end |
#serie ⇒ Object
Returns the value of attribute serie.
3 4 5 |
# File 'lib/bibliogem/Referencia.rb', line 3 def serie @serie end |
#titulo ⇒ Object
Returns the value of attribute titulo.
3 4 5 |
# File 'lib/bibliogem/Referencia.rb', line 3 def titulo @titulo end |
Instance Method Details
#<=>(other) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bibliogem/Referencia.rb', line 27 def <=> other if(@autores == other.autores) if(@fecha == other.fecha) if(@titulo == other.titulo) return 0 else aux=[@titulo, other.titulo] aux.sort_by! do |t| t end if(aux.first == @titulo) return -1 end return 1 end elsif(@fecha < other.fecha) return -1 else return 1 end else aux=[@autores, other.autores] aux.sort_by! do |t| t end if(aux.first == @autores) return -1 end return 1 end end |
#comprobar ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bibliogem/Referencia.rb', line 7 def if !aut.any? raise ArgumentError.new("Error: Se requiere al menos un autor") end if tit.nil? raise ArgumentError.new("Error: Se requiere un tiulo") end if edi.nil? raise ArgumentError.new("Error: Se requiere una editorial") end if ne.nil? raise ArgumentError.new("Error Se requiere un numero de edicion") end if fe.nil? raise ArgumentError.new("Error: Se requiere una fecha con formato %d-%m-%Y") end if is10.nil? && is13.nil? raise ArgumentError.new("Error: Se requiere al menos un codigo isbn") end end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/bibliogem/Referencia.rb', line 58 def to_s "#{@autores}, #{@titulo}, #{@serie}, #{@editorial}, #{@nedicion}, #{@fecha}, #{@isbn10}, #{@isbn13}" end |