Class: Arb::Files::Solution
- Inherits:
-
Object
- Object
- Arb::Files::Solution
- Defined in:
- lib/arb/files/solution.rb
Class Method Summary collapse
Class Method Details
.create(year:, day:) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/arb/files/solution.rb', line 4 def self.create(year:, day:) year_directory = File.join("src", year) Dir.mkdir(year_directory) unless Dir.exist?(year_directory) file_path = File.join(year_directory, "#{day}.rb") if File.exist?(file_path) puts "Already exists: #{file_path}" else File.write(file_path, template(year:, day:)) end file_path end |
.template(year:, day:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/arb/files/solution.rb', line 19 def self.template(year:, day:) <<~SRC # https://adventofcode.com/#{year}/day/#{day.delete_prefix("0")} module Year#{year} class Day#{day} def part_1(input_file) lines = input_file.readlines(chomp: true) nil end def part_2(input_file) lines = input_file.readlines(chomp: true) nil end end end SRC end |