Sha256: 629159e5613f5a89e7f24d334743ff786cc63252b5fbf4fe35cb93ff001894c3

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 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
        # TODO raise error in 0.5.0
        # raise ArgumentError, "Holidays in #{country} are not currently supported"
        logger.warn "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

1 entries across 1 versions & 1 rubygems

Version Path
prophet-rb-0.4.2 lib/prophet/holidays.rb