Sha256: d3f8e8a1407170008d441c1c72f7faa3c1c5bc98e01c4b139b03ddef007ec9fe

Contents?: true

Size: 760 Bytes

Versions: 4

Compression:

Stored size: 760 Bytes

Contents

module Prophet
  module Holidays
    def get_holiday_names(country)
      years = (1995..2045).to_a
      holiday_names = make_holidays_df(years, country)["holiday"].uniq
      if holiday_names.size == 0
        raise ArgumentError, "Holidays in #{country} are not currently supported"
      end
      holiday_names
    end

    def make_holidays_df(year_list, country)
      holidays_df[(holidays_df["country"] == country) & (holidays_df["year"].in?(year_list))][["ds", "holiday"]]
    end

    # TODO improve performance
    def holidays_df
      @holidays_df ||= begin
        holidays_file = File.expand_path("../../data-raw/generated_holidays.csv", __dir__)
        Rover.read_csv(holidays_file, converters: [:date, :numeric])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prophet-rb-0.5.3 lib/prophet/holidays.rb
prophet-rb-0.5.2 lib/prophet/holidays.rb
prophet-rb-0.5.1 lib/prophet/holidays.rb
prophet-rb-0.5.0 lib/prophet/holidays.rb