Sha256: cf9a223057c9f1403c24110ac917b30fcbc05ce1167db58564be9ac9de133b04

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require "active_support"
require "active_support/core_ext"
require "google/apis/calendar_v3"

require "holidays_from_google_calendar/cache"
require "holidays_from_google_calendar/cache_unit"
require "holidays_from_google_calendar/client"
require "holidays_from_google_calendar/configuration"
require "holidays_from_google_calendar/holiday"
require "holidays_from_google_calendar/version"

module HolidaysFromGoogleCalendar
  class Holidays
    def initialize
      @configuration = Configuration.new
      yield @configuration
      @client = Client.new(@configuration)
    end

    def in_year(date)
      @client.retrieve(
        date_min: date.beginning_of_year,
        date_max: date.end_of_year
      )
    end

    def in_month(date)
      @client.retrieve(
        date_min: date.beginning_of_month,
        date_max: date.end_of_month
      )
    end

    def holiday?(date)
      return true if date.wday.in?([0, 6]) # If Sunday or Saturday
      @client.retrieve(date_min: date, date_max: date).size > 0
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
holidays_from_google_calendar-0.4.7 lib/holidays_from_google_calendar.rb
holidays_from_google_calendar-0.4.6 lib/holidays_from_google_calendar.rb
holidays_from_google_calendar-0.4.5 lib/holidays_from_google_calendar.rb
holidays_from_google_calendar-0.4.4 lib/holidays_from_google_calendar.rb