Class: BiblioRefs::ListAPA

Inherits:
Object
  • Object
show all
Defined in:
lib/biblio_refs/list_apa.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*nodo) ⇒ ListAPA

Constructor de la clase ListAPA



7
8
9
10
# File 'lib/biblio_refs/list_apa.rb', line 7

def initialize(*nodo)
  @list = BiblioRefs::List.new(*nodo)
  sort_list
end

Instance Attribute Details

#listObject

Returns the value of attribute list.



4
5
6
# File 'lib/biblio_refs/list_apa.rb', line 4

def list
  @list
end

Instance Method Details

#sort_listObject

Método que ordena el atributo ‘list’ mediante la función ‘sort’



13
14
15
16
17
18
19
20
# File 'lib/biblio_refs/list_apa.rb', line 13

def sort_list
  array = @list.sort
  @list =  BiblioRefs::List.new(array[0])
  array.shift
  array.each do |ref|
    @list.push(ref)
  end
end

#to_sObject

Método que devuelve una cadena de carácteres formateada de los objetos de la clase ListAPA



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/biblio_refs/list_apa.rb', line 23

def to_s
  class << @list
    def to_s
      aux = @head
      string = "Lista APA: "
      while aux[:next] do
        string += "#{aux[:value]}" + "\n\n"
        aux = aux[:next]
      end
      string += "#{aux[:value]}"
    end
  end
  @list.to_s
end