class AocCli::Paths::Day

Attributes

day[R]
user[R]
year[R]

Public Class Methods

new(u:Metafile.get(:user), y:Metafile.get(:year), d:) click to toggle source
# File lib/aoc_cli/paths.rb, line 31
def initialize(u:Metafile.get(:user), 
                           y:Metafile.get(:year), d:)
        @user = Validate.user(u)
        @year = Validate.year(y)
        @day  = Validate.day(d)
end

Public Instance Methods

cache_and_local(f:) click to toggle source
# File lib/aoc_cli/paths.rb, line 71
def cache_and_local(f:)
        [cache_path(f:f), local(f:f)]
end
cache_dir() click to toggle source
# File lib/aoc_cli/paths.rb, line 61
def cache_dir
        "#{Dir.home}/.cache/aoc-cli/"\
        "#{user}/#{year}/#{day_dir}" 
end
cache_path(f:) click to toggle source
# File lib/aoc_cli/paths.rb, line 68
def cache_path(f:)
        "#{cache_dir}/#{filename(f:f)}"
end
create_cache() click to toggle source
# File lib/aoc_cli/paths.rb, line 37
def create_cache
        FileUtils.mkdir_p(cache_dir) unless Dir.exist?(cache_dir)
end
day_dir() click to toggle source
# File lib/aoc_cli/paths.rb, line 53
def day_dir
        day.to_i < 10 ? 
                "#{prefix}0#{day}" : 
                "#{prefix}#{day}"
end
filename(f:) click to toggle source
# File lib/aoc_cli/paths.rb, line 43
def filename(f:)
        case f.to_sym
        when :Input  then "input"
        when :Puzzle then "#{day}.md"
        when :meta   then ".meta"
        end 
end
in_day?() click to toggle source
# File lib/aoc_cli/paths.rb, line 50
def in_day?
        Metafile.type == :DAY 
end
local(f:) click to toggle source
# File lib/aoc_cli/paths.rb, line 65
def local(f:)
        "#{local_dir}/#{filename(f:f)}"
end
local_dir() click to toggle source
# File lib/aoc_cli/paths.rb, line 58
def local_dir
        in_day? ? "." : "#{day_dir}"
end
prefix() click to toggle source
# File lib/aoc_cli/paths.rb, line 40
def prefix
        Prefs.string(key:"day_dir_prefix")
end