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
39
40
41
|
# File 'lib/argentine_holidays.rb', line 14
def self.fetch(year)
unless defined? @@dates
@@dates = []
end
unless @@dates.any? {|i| i.year == year.to_i }
begin
doc = Nokogiri::HTML(open("http://www.mininterior.gov.ar/asuntos_politicos_y_alectorales/dinap/feriados/feriados#{year}.php"))
rescue OpenURI::HTTPError
return []
end
tables = doc.css('div#info table')
tables[0].css('tr')[1..-1].each {|i|
@@dates += parse_date(i.children[1].text, year)
}
tables[1].css('tr')[1..-1].each {|i|
@@dates += parse_date(i.children[3].text, year)
}
@@dates.sort!
end
return @@dates.select {|i| i.year == year }
end
|