Class: ReferenciaBase
- Inherits:
-
Object
- Object
- ReferenciaBase
- Includes:
- Comparable
- Defined in:
- lib/referencia/referencia.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#m_anio ⇒ Object
readonly
Returns the value of attribute m_anio.
-
#m_autor_formato ⇒ Object
readonly
Returns the value of attribute m_autor_formato.
-
#m_autores ⇒ Object
readonly
Returns the value of attribute m_autores.
-
#m_titulo ⇒ Object
readonly
Returns the value of attribute m_titulo.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#format_autor ⇒ Object
coloca los nombres de los autores y se guarda el formato de dicho nombre.
-
#format_titulo ⇒ Object
formato del titulo.
-
#initialize(a_autores, a_titulo, a_anio) ⇒ ReferenciaBase
constructor
A new instance of ReferenciaBase.
Constructor Details
#initialize(a_autores, a_titulo, a_anio) ⇒ ReferenciaBase
Returns a new instance of ReferenciaBase.
21 22 23 24 25 |
# File 'lib/referencia/referencia.rb', line 21 def initialize(a_autores, a_titulo, a_anio) @m_autores,@m_titulo,@m_anio = a_autores,a_titulo,a_anio format_autor format_titulo end |
Instance Attribute Details
#m_anio ⇒ Object (readonly)
Returns the value of attribute m_anio.
4 5 6 |
# File 'lib/referencia/referencia.rb', line 4 def m_anio @m_anio end |
#m_autor_formato ⇒ Object (readonly)
Returns the value of attribute m_autor_formato.
4 5 6 |
# File 'lib/referencia/referencia.rb', line 4 def m_autor_formato @m_autor_formato end |
#m_autores ⇒ Object (readonly)
Returns the value of attribute m_autores.
4 5 6 |
# File 'lib/referencia/referencia.rb', line 4 def m_autores @m_autores end |
#m_titulo ⇒ Object (readonly)
Returns the value of attribute m_titulo.
4 5 6 |
# File 'lib/referencia/referencia.rb', line 4 def m_titulo @m_titulo end |
Instance Method Details
#<=>(other) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/referencia/referencia.rb', line 6 def <=>(other) return nil if other.nil? #Si el valor con el que se compara es nil, saldrá y retornara que lo es t_comparaciones=self.m_autor_formato <=> other.m_autor_formato if(t_comparaciones == 0) t_comparaciones=self.m_anio <=> other.m_anio if (t_comparaciones == 0) t_comparaciones=self.m_anio <=> other.m_titulo if(t_comparaciones == 0) t_comparaciones end end end t_comparaciones end |
#format_autor ⇒ Object
coloca los nombres de los autores y se guarda el formato de dicho nombre
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/referencia/referencia.rb', line 27 def format_autor @m_autor_formato = [] @m_autores.each do |autor| auxiliar="" autor = autor.split(" ") autor = autor.reverse autor.each_with_index do |aux, i| #auxiliar.clear if (i<1) auxiliar += aux.capitalize auxiliar += "," else auxiliar += aux[0].capitalize auxiliar += "." end end @m_autor_formato.push(auxiliar) end #para poner los autores, si son varios, separados por & t_aux =@m_autor_formato @m_autor_formato = "" t_aux.each_with_index do |aux,i| if i<@m_autores.size-1 @m_autor_formato+=aux @m_autor_formato+=" & " else @m_autor_formato+=aux end end end |
#format_titulo ⇒ Object
formato del titulo
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/referencia/referencia.rb', line 61 def format_titulo t_titulo_formateado = "" aux = @m_titulo.split". " aux.each do |aux1| t_titulo_formateado += aux1.capitalize t_titulo_formateado += ". " end @m_titulo = t_titulo_formateado @m_titulo=@m_titulo.chop.chop # de esta manera elimino las dos últimas posiciones ". " que se añaden al final end |