Class: AdventOfCode::Commands::Download
- Defined in:
- lib/advent_of_code_cli/commands/download.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(year:, day:) ⇒ Download
constructor
A new instance of Download.
Constructor Details
#initialize(year:, day:) ⇒ Download
Returns a new instance of Download.
9 10 11 12 |
# File 'lib/advent_of_code_cli/commands/download.rb', line 9 def initialize(year:, day:) @year = year super(day: day) end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/advent_of_code_cli/commands/download.rb', line 14 def execute raise MissingCookieError unless && say("Fetching input...") input = fetch_input unless Dir.exist?("inputs") say("Creating inputs directory...") Dir.mkdir("inputs") end say("Writing input to #{input_file_name}...") create_file(input_file_name, input) say("Done!", :green) end |