9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/arb/files/input.rb', line 9
def self.download(year:, day:, notify_exists: true)
Dir.mkdir("input") unless Dir.exist?("input")
year_directory = File.join("input", year)
Dir.mkdir(year_directory) unless Dir.exist?(year_directory)
file_path = File.join(year_directory, "#{day}.txt")
if File.exist?(file_path)
puts "Already exists: #{file_path}" if notify_exists
else
aoc_api = Api::Aoc.new(cookie: ENV["AOC_COOKIE"])
response = aoc_api.input(year:, day:)
File.write(file_path, response)
end
file_path
end
|