Class: Referencia
- Inherits:
-
Object
show all
- Includes:
- Comparable
- Defined in:
- lib/bibliogem/Referencia.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(aut, tit, ser, edi, ne, fe, is10, is13) ⇒ Referencia
Returns a new instance of Referencia.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/bibliogem/Referencia.rb', line 4
def initialize(aut,tit,ser,edi,ne,fe,is10,is13)
if aut.any?
@autores=aut
else
raise ArgumentError.new("Error: Se requiere al menos un autor")
end
if !tit.nil?
@titulo=tit
else
raise ArgumentError.new("Error: Se requiere un tiulo")
end
@serie=ser
if !edi.nil?
@editorial=edi
else
raise ArgumentError.new("Error: Se requiere una editorial")
end
if !ne.nil?
@nedicion=ne
else
raise ArgumentError.new("Error Se requiere un numero de edicion")
end
if !fe.nil?
@fecha=Date::strptime(fe, "%d-%m-%Y")
else
raise ArgumentError.new("Error: Se requiere una fecha con formato %d-%m-%Y")
end
if !is10.nil? || !is13.nil?
@isbn10=is10
@isbn13=is13
else
raise ArgumentError.new("Error: Se requiere al menos un codigo isbn")
end
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
|
Class Method Details
.crear(&block) ⇒ Object
40
41
42
43
44
|
# File 'lib/bibliogem/Referencia.rb', line 40
def self.crear &block
newref = Referencia.new([""],"","","",0,"01-01-1990",[],[])
newref.evaluar(&block)
return newref
end
|
Instance Method Details
#<=>(referencia) ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'lib/bibliogem/Referencia.rb', line 51
def <=>(referencia)
if(@autores[0] <=> referencia.autores[0])
if(@autores.count<=>referencia.autores.count)
if(@fecha <=> referencia.fecha)
@titulo <=> referencia.titulo
end
end
end
end
|
#AUTOR(nombre) ⇒ Object
72
73
74
|
# File 'lib/bibliogem/Referencia.rb', line 72
def AUTOR nombre
@autores << nombre
end
|
#EDICION(edicion) ⇒ Object
88
89
90
|
# File 'lib/bibliogem/Referencia.rb', line 88
def EDICION edicion
@nedicion = edicion
end
|
#EDITORIAL(edit) ⇒ Object
84
85
86
|
# File 'lib/bibliogem/Referencia.rb', line 84
def EDITORIAL edit
@editorial = edit
end
|
#evaluar(&block) ⇒ Object
46
47
48
49
|
# File 'lib/bibliogem/Referencia.rb', line 46
def evaluar &block
@autores = []
instance_eval &block
end
|
#FECHA(fecha) ⇒ Object
92
93
94
|
# File 'lib/bibliogem/Referencia.rb', line 92
def FECHA fecha
@fecha = fecha
end
|
#ISBN10(isbn) ⇒ Object
96
97
98
|
# File 'lib/bibliogem/Referencia.rb', line 96
def ISBN10 isbn
@isbn10 << isbn
end
|
#ISBN13(isbn) ⇒ Object
100
101
102
|
# File 'lib/bibliogem/Referencia.rb', line 100
def ISBN13 isbn
@isbn13 << isbn
end
|
#SERIE(serie) ⇒ Object
80
81
82
|
# File 'lib/bibliogem/Referencia.rb', line 80
def SERIE serie
@serie = serie
end
|
#TITULO(nombre) ⇒ Object
76
77
78
|
# File 'lib/bibliogem/Referencia.rb', line 76
def TITULO nombre
@titulo = nombre
end
|
#to_s ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/bibliogem/Referencia.rb', line 61
def to_s
splitnames = []
@autores.each do |nombre|
listanombres = nombre.split
nombre = listanombres[0]
apellidos = listanombres[1..-1].join(" ").capitalize
splitnames.push(apellidos + ", " + nombre[0])
end
"Autor: #{splitnames.join(" & ")} (#{@fecha}). Titulo del libro: #{@titulo.capitalize} (#{@nedicion}). Lugar de publicacion: #{@editorial}"
end
|