Class: AocCli::Solve::Attempt
- Inherits:
-
Object
- Object
- AocCli::Solve::Attempt
- Defined in:
- lib/aoc_cli/solve.rb
Instance Attribute Summary collapse
-
#answer ⇒ Object
readonly
Returns the value of attribute answer.
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#part ⇒ Object
readonly
Returns the value of attribute part.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #check ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(u: Metafile.get(:user), y: Metafile.get(:year), d: Metafile.get(:day), p: Metafile.get(:part), a:) ⇒ Attempt
constructor
A new instance of Attempt.
- #raw ⇒ Object
- #respond ⇒ Object
Constructor Details
#initialize(u: Metafile.get(:user), y: Metafile.get(:year), d: Metafile.get(:day), p: Metafile.get(:part), a:) ⇒ Attempt
Returns a new instance of Attempt.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/aoc_cli/solve.rb', line 8 def initialize(u:Metafile.get(:user), y:Metafile.get(:year), d:Metafile.get(:day), p:Metafile.get(:part), a:) @user = Validate.user(u) @year = Validate.year(y) @day = Validate.day(d) @part = Validate.part(p) @answer = Validate.ans(attempt:self, ans:a) end |
Instance Attribute Details
#answer ⇒ Object (readonly)
Returns the value of attribute answer.
7 8 9 |
# File 'lib/aoc_cli/solve.rb', line 7 def answer @answer end |
#day ⇒ Object (readonly)
Returns the value of attribute day.
7 8 9 |
# File 'lib/aoc_cli/solve.rb', line 7 def day @day end |
#part ⇒ Object (readonly)
Returns the value of attribute part.
7 8 9 |
# File 'lib/aoc_cli/solve.rb', line 7 def part @part end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'lib/aoc_cli/solve.rb', line 7 def user @user end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
7 8 9 |
# File 'lib/aoc_cli/solve.rb', line 7 def year @year end |
Instance Method Details
#check ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/aoc_cli/solve.rb', line 25 def check case raw when /#{CORRECT}/ then :Correct when /#{INCORRECT}/ then :Incorrect when /#{WAIT}/ then :Wait end end |
#exists? ⇒ Boolean
18 19 20 |
# File 'lib/aoc_cli/solve.rb', line 18 def exists? Database::Attempt.new(attempt:self) end |
#raw ⇒ Object
21 22 23 24 |
# File 'lib/aoc_cli/solve.rb', line 21 def raw @raw ||= Tools::Post.new(u:user, y:year, d:day, data:{level:part, answer:answer}).plain end |
#respond ⇒ Object
32 33 34 35 36 37 |
# File 'lib/aoc_cli/solve.rb', line 32 def respond Respond.const_get(check) .new(attempt:self) .respond .react end |