Class: AdventOfCodeGenerator::Generator
- Inherits:
-
Object
- Object
- AdventOfCodeGenerator::Generator
- Defined in:
- lib/advent_of_code_generator/generator.rb
Overview
Creates directory structure and files for daily Advent of Code puzzles:
Generates a file structure like:
username/
│
└── year_2024/
|
└── day_01/
├── day_01.rb
├── day_01_spec.rb
├── data.txt
└── PUZZLE_DESCRIPTION.md
Defined Under Namespace
Classes: FileData
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(options, scraped_data) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(options, scraped_data) ⇒ Generator
Returns a new instance of Generator.
23 24 25 26 27 28 29 |
# File 'lib/advent_of_code_generator/generator.rb', line 23 def initialize(, scraped_data) @year = [:year].to_s @day = [:day].to_s.rjust(2, "0") # Ensures day is two digits (e.g., "01" instead of "1") @username = [:username].gsub(/[_\-\.\s]/, "") @session = [:session] @scraped_data = scraped_data end |
Instance Method Details
#call ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/advent_of_code_generator/generator.rb', line 31 def call FileUtils.mkdir_p(daily_directory) [puzzle_description, data_file, main_file, spec_file].each do |file_data| generate_file(file_data) end end |