Class: Referencias

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/biblio/class.rb

Direct Known Subclasses

Documento_elec, Libro, Periodico

Instance Method Summary collapse

Constructor Details

#initialize(titulo) ⇒ Referencias

Returns a new instance of Referencias.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/biblio/class.rb', line 32

def initialize(titulo)
  
  tit = titulo.split(' ')
  tit.each do |word|
    if word.length > 3
      word.capitalize!
    else
      word.downcase!
    end
    if word == tit[0]
      word.capitalize!
    end
  end

  @titulo = tit.join(' ')
  @autor = @autor[0...-3]
end

Instance Method Details

#<=>(other) ⇒ Object



51
52
53
54
# File 'lib/biblio/class.rb', line 51

def <=> (other)
  
  @publicacion <=> other.publicacion 
end

#autor(autor) ⇒ Object



19
20
21
22
23
# File 'lib/biblio/class.rb', line 19

def autor(autor)
  
  @autor = "" if @autor.nil?
  @autor << autores(autor[:nombre], autor[:apellido])
end

#autores(nombre, apellido) ⇒ Object



25
26
27
28
29
# File 'lib/biblio/class.rb', line 25

def autores(nombre, apellido)
  str = "#{apellido}, "
  str << "#{nombre[0]}."
  str << " & "
end

#editorial(editorial) ⇒ Object



7
8
9
10
# File 'lib/biblio/class.rb', line 7

def editorial(editorial)
  
  @editorial = editorial
end

#publicacion(publicacion) ⇒ Object



13
14
15
16
# File 'lib/biblio/class.rb', line 13

def publicacion(publicacion)
  
  @publicacion = publicacion
end