Class: Holidays::Ar::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/holidays/ar/loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(year = Date.today.year) ⇒ Loader

Returns a new instance of Loader.



6
7
8
# File 'lib/holidays/ar/loader.rb', line 6

def initialize(year=Date.today.year)
  @year = year
end

Instance Method Details

#execObject



10
11
12
13
14
15
16
17
18
19
20
# 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