Class: Aocli::AdventOfCode::Client
- Inherits:
-
Object
- Object
- Aocli::AdventOfCode::Client
- Defined in:
- lib/aocli/advent_of_code/client.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Instance Method Summary collapse
- #get_problem_description(year:, day:) ⇒ Object
- #get_problem_inputs(year:, day:) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
17 18 19 |
# File 'lib/aocli/advent_of_code/client.rb', line 17 def conn @conn end |
Instance Method Details
#get_problem_description(year:, day:) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/aocli/advent_of_code/client.rb', line 42 def get_problem_description(year:, day:) res = conn.get("/#{year}/day/#{day}") case res.status when 200 Response.new(status: res.status, body: res.body, should_retry: false) when 404 Response.new( status: res.status, body: res.body, should_retry: res.body.include?("Please don't repeatedly request this endpoint before it unlocks!"), ) else Response.new( status: res.status, body: res.body, should_retry: false, ) end end |
#get_problem_inputs(year:, day:) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/aocli/advent_of_code/client.rb', line 24 def get_problem_inputs(year:, day:) res = conn.get("/#{year}/day/#{day}/input") case res.status when 200 Response.new( status: res.status, body: res.body, should_retry: false, ) else Response.new( status: res.status, body: res.body, should_retry: false, ) end end |