class Holidays::Ar::Loader

Public Class Methods

new(year=Date.today.year) click to toggle source
# File lib/holidays/ar/loader.rb, line 6
def initialize(year=Date.today.year)
  @year = year
end

Public Instance Methods

exec() click to toggle source
# File lib/holidays/ar/loader.rb, line 10
def exec
  holidays = []
  doc.search('.mes').each_with_index do |mes, index|
    month = index + 1
    mes.search('.bg-primary', '.bg-nl', '.bg-success').each do |day|
      holidays << Date.new(@year, month, day.text.to_i)
    end
  end

  holidays
end

Private Instance Methods

doc() click to toggle source
# File lib/holidays/ar/loader.rb, line 32
def doc
  Nokogiri::HTML(open(uri))
end
uri() click to toggle source
# File lib/holidays/ar/loader.rb, line 24
def uri
  if @year == Date.today.year
    "https://www.argentina.gob.ar/interior/feriados"
  else
    "https://www.argentina.gob.ar/interior/feriados#{@year}"
  end
end