Class: Aocli::Commands::StartDay

Inherits:
Object
  • Object
show all
Defined in:
lib/aocli/commands/start_day.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date:, output_destination:) ⇒ StartDay

Returns a new instance of StartDay.



11
12
13
14
15
16
# File 'lib/aocli/commands/start_day.rb', line 11

def initialize(date:, output_destination:)
  @date = date
  @output_destination = output_destination
  @main_file_path = File.join(output_destination, date.year.to_s, "day_#{date.day}", "main.rb")
  @input_file_path = File.join(output_destination, date.year.to_s, "day_#{date.day}", "input.txt")
end

Class Method Details

.run!(options) ⇒ Object



4
5
6
7
8
9
# File 'lib/aocli/commands/start_day.rb', line 4

def self.run!(options)
  new(
    date: options[:date],
    output_destination: options[:output_destination],
  ).run!
end

Instance Method Details

#run!Object



18
19
20
21
22
23
# File 'lib/aocli/commands/start_day.rb', line 18

def run!
  Aocli::FileUtils.touch_file(main_file_path)
  Aocli::FileUtils.touch_file(input_file_path)
  File.write(main_file_path, main_content)
  File.write(input_file_path, input_content)
end