class AocCli::Solve::Attempt

Attributes

answer[R]
day[R]
part[R]
user[R]
year[R]

Public Class Methods

new(u:Metafile.get(:user), y:Metafile.get(:year), d:Metafile.get(:day), p:Metafile.get(:part), a:) click to toggle source
# 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

Public Instance Methods

check() click to toggle source
# 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?() click to toggle source
# File lib/aoc_cli/solve.rb, line 18
def exists?
        Database::Attempt.new(attempt:self)
end
raw() click to toggle source
# 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() click to toggle source
# File lib/aoc_cli/solve.rb, line 32
def respond
        Respond.const_get(check)
                .new(attempt:self)
                .respond
                .react
end