Sha256: 4b608c469d6c5b91e52d1ac6eecf65d3e25bafd4de022c6c665adc1da5b6e774

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

# frozen_string_literal: true

require_relative "aoc_toolkit/version"

module AocToolkit
  TIMEZONE = "Eastern Time (US & Canada)"
  QUIZ_DIR = File.join(File.dirname(__FILE__), "..", "quiz")

  class Error < StandardError; end

  class << self
    def bootstrap
      year_dir = File.join(QUIZ_DIR, year.to_s)
      FileUtils.mkdir_p(year_dir)
      days_active.map do |active_date|
        day_dir = File.join(year_dir, active_date.day.to_s.rjust(2, "0"))
        FileUtils.mkdir_p(day_dir)
      end
    end

    private

    def year
      Time.current.year
    end

    def quiz_days
      (1..25).to_a.map { |day| Date.new(year, 12, day) }
    end

    def days_active
      quiz_days.filter { |day| day <= Date.today }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aoc_toolkit-0.0.1 lib/aoc_toolkit.rb