class AocCli::Day::Pages
Attributes
files[R]
use_cache[R]
Public Class Methods
new(u:Metafile.get(:user), y:Metafile.get(:year), d:Metafile.get(:day), f:[:Input, :Puzzle], use_cache:true)
click to toggle source
Calls superclass method
AocCli::Day::Init::new
# File lib/aoc_cli/day.rb, line 25 def initialize(u:Metafile.get(:user), y:Metafile.get(:year), d:Metafile.get(:day), f:[:Input, :Puzzle], use_cache:true) super(u:u, y:y, d:d) @files = f @use_cache = use_cache end
Public Instance Methods
cache()
click to toggle source
# File lib/aoc_cli/day.rb, line 38 def cache @cache ||= Cache.new(d:day, f:files).query end
copy(file:)
click to toggle source
# File lib/aoc_cli/day.rb, line 41 def copy(file:) File.write(paths.local(f:file), cache[file]) end
download(page:)
click to toggle source
# File lib/aoc_cli/day.rb, line 44 def download(page:) req = Requests.const_get(page) .new(u:user, y:year, d:day) .write(to:paths.cache_and_local(f:page)) req.init_stats if page == :Puzzle end
load()
click to toggle source
# File lib/aoc_cli/day.rb, line 34 def load files.each do |file| use_cache && cache[file] ? copy(file:file) : download(page:file) end end