Class: RList

Inherits:
DList show all
Defined in:
lib/dsl/ref_list.rb

Instance Attribute Summary collapse

Attributes inherited from DList

#end_, #head

Instance Method Summary collapse

Methods inherited from DList

#each, #extract_all, #extract_end, #extract_head, #insert_e, #insert_empty, #insert_end, #insert_h, #insert_head, #reverse

Constructor Details

#initialize(&block) ⇒ RList

Returns a new instance of RList.



4
5
6
# File 'lib/dsl/ref_list.rb', line 4

def initialize(&block)
    instance_eval &block
end

Instance Attribute Details

#letterObject

letra para los sufijos de los años



3
4
5
# File 'lib/dsl/ref_list.rb', line 3

def letter
  @letter
end

Instance Method Details

#insert(content) ⇒ Object



8
9
10
11
12
13
# File 'lib/dsl/ref_list.rb', line 8

def insert(content)

    insert_h(content)
    quitarsufijos
    ordenar_interno
end

#ordenar_internoObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/dsl/ref_list.rb', line 16

def ordenar_interno
    orden = sort_by{|node| node["value"]}
    if (orden.count > 1)
    extract_all
    for i in 0..orden.count-1
    insert_e(orden[i]["value"])
  end
  sufijos
end
end

#quitarsufijosObject



47
48
49
50
51
52
53
# File 'lib/dsl/ref_list.rb', line 47

def quitarsufijos
    aux=@head
    while aux!=nil
   aux["value"].p_date=aux["value"].p_date.tr('^0-9', '')
    aux = aux["next"]    
end
end

#salida_funcionalObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/dsl/ref_list.rb', line 55

def salida_funcional
libro = Proc.new{|node| 
fullnames = ""
         i=0
 while i < node["value"].author_name.count
if i != node["value"].author_name.count-1
 fullnames= fullnames + "#{node["value"].author_surname[i]}, #{node["value"].author_name[i][0]}. & "
else
 fullnames= fullnames + "#{node["value"].author_surname[i]}, #{node["value"].author_name[i][0]}."
end
 i=i+1
end
     "#{fullnames} (#{node["value"].p_date}). #{node["value"].title_} (#{node["value"].edit_num}) (#{node["value"].volume}). #{node["value"].p_place}: #{node["value"].p_house}."}
     
     libroeditado = Proc.new{|node| 
       editors = ""
fullnames = ""
         i=0
 while i < node["value"].author_name.count
if i != node["value"].author_name.count-1
 fullnames= fullnames + "#{node["value"].author_surname[i]}, #{node["value"].author_name[i][0]}. & "
else
 fullnames= fullnames + "#{node["value"].author_surname[i]}, #{node["value"].author_name[i][0]}."
end
 i=i+1
end
i=0
  while i < node["value"].editor_name.count
if i == node["value"].editor_name.count-1
 editors= editors + "#{node["value"].editor_name[i][0]}. #{node["value"].editor_surname[i]}"
elsif i == node["value"].editor_name.count-2
 editors= editors + "#{node["value"].editor_name[i][0]}. #{node["value"].editor_surname[i]} & "
else
editors= editors + "#{node["value"].editor_name[i][0]}. #{node["value"].editor_surname[i]}, "
end
 i=i+1
end
     "#{fullnames} (#{node["value"].p_date}). #{node["value"].title_a}. En #{editors} (comps), #{node["value"].title_} (pp. #{node["value"].page}) (#{node["value"].edit_num}) (#{node["value"].volume}). #{node["value"].p_place}: #{node["value"].p_house}."
}
   periodico= Proc.new{|node|
    fullnames = ""
         i=0
 while i < node["value"].author_name.count
if i != node["value"].author_name.count-1
 fullnames= fullnames + "#{node["value"].author_surname[i]}, #{node["value"].author_name[i][0]}. & "
else
 fullnames= fullnames + "#{node["value"].author_surname[i]}, #{node["value"].author_name[i][0]}."
end
 i=i+1
end
     "#{fullnames} (#{node["value"].p_date}). #{node["value"].title_a}. #{node["value"].title_}, pp. #{node["value"].page}."
   }
   
   edoc= Proc.new{|node|
          fullnames = ""
         i=0
 while i < node["value"].author_name.count
if i != node["value"].author_name.count-1
 fullnames= fullnames + "#{node["value"].author_surname[i]}, #{node["value"].author_name[i][0]}. & "
else
 fullnames= fullnames + "#{node["value"].author_surname[i]}, #{node["value"].author_name[i][0]}."
end
 i=i+1
end
if node["value"].medium =="En línea"
     "#{fullnames} (#{node["value"].p_date}). #{node["value"].title_} (#{node["value"].edit_num}), [#{node["value"].medium}]. #{node["value"].p_place}: #{node["value"].p_house}. Disponible en: #{node["value"].url} [#{node["value"].a_date}]."
else
    "#{fullnames} (#{node["value"].p_date}). #{node["value"].title_} (#{node["value"].edit_num}), [#{node["value"].medium}]. #{node["value"].p_place}: #{node["value"].p_house} [#{node["value"].a_date}]."
end
   }
     aux = @head
   cadena=""
while aux!=nil
   if aux["next"]!=nil
       if aux["value"].class.to_s=="Book"
   cadena= cadena+"#{libro.call(aux)}\n"
   elsif aux["value"].class.to_s=="EBook"
   cadena= cadena+"#{libroeditado.call(aux)}\n"
   elsif aux["value"].class.to_s=="Newspaper"
   cadena= cadena+"#{periodico.call(aux)}\n"
   elsif aux["value"].class.to_s=="EDoc"
   cadena= cadena+"#{edoc.call(aux)}\n"
end
else
    if aux["value"].class.to_s=="Book"
   cadena= cadena+"#{libro.call(aux)}\n"
   elsif aux["value"].class.to_s=="EBook"
   cadena= cadena+"#{libroeditado.call(aux)}\n"
   elsif aux["value"].class.to_s=="Newspaper"
   cadena= cadena+"#{periodico.call(aux)}\n"
   elsif aux["value"].class.to_s=="EDoc"
   cadena= cadena+"#{edoc.call(aux)}\n"
end
end
   aux=aux["next"]
end
cadena
end

#sufijosObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dsl/ref_list.rb', line 27

def sufijos
    aux=@head
    letter="a"
    while aux!=nil
    year = aux["value"].p_date
    while  aux["next"]!=nil && aux["value"].author_surname==aux["next"]["value"].author_surname && year==aux["next"]["value"].p_date
    aux["value"].p_date=aux["value"].p_date + letter
    year=aux["next"]["value"].p_date
    aux=aux["next"]
    letter=letter.next
         if  aux["next"]==nil || (aux["value"].author_surname!=aux["next"]["value"].author_surname && aux["value"].p_date!=aux["next"]["value"].p_date) 
        aux["value"].p_date=aux["value"].p_date + letter
    end

end
  letter="a"
    aux = aux["next"]    
end
end

#to_sObject



154
155
156
# File 'lib/dsl/ref_list.rb', line 154

def to_s
    salida_funcional
end