Class: AocRb::AocApi
Instance Method Summary collapse
-
#initialize(session) ⇒ AocApi
constructor
A new instance of AocApi.
- #puzzle_input(year, day) ⇒ Object
- #puzzle_instructions(year, day) ⇒ Object
- #submit_answer(year, day, level, answer) ⇒ Object
Constructor Details
#initialize(session) ⇒ AocApi
Returns a new instance of AocApi.
8 9 10 |
# File 'lib/aoc_rb/aoc_api.rb', line 8 def initialize(session) @options = { headers: { 'Cookie' => "session=#{session}" }, follow_redirects: false } end |
Instance Method Details
#puzzle_input(year, day) ⇒ Object
16 17 18 |
# File 'lib/aoc_rb/aoc_api.rb', line 16 def puzzle_input(year, day) self.class.get(input_path(year, day), @options) end |
#puzzle_instructions(year, day) ⇒ Object
12 13 14 |
# File 'lib/aoc_rb/aoc_api.rb', line 12 def puzzle_instructions(year, day) self.class.get(puzzle_path(year, day), @options) end |
#submit_answer(year, day, level, answer) ⇒ Object
20 21 22 23 |
# File 'lib/aoc_rb/aoc_api.rb', line 20 def submit_answer(year, day, level, answer) = @options.merge({ body: { level: level.to_s, answer: answer.to_s } }) self.class.post(answer_path(year, day), ) end |