Class: AocCli::Solve::Respond::Incorrect
Instance Attribute Summary
Attributes inherited from Response
#attempt
Instance Method Summary
collapse
Methods inherited from Response
#initialize
Instance Method Details
#high ⇒ Object
79
80
81
|
# File 'lib/aoc_cli/solve.rb', line 79
def high
/too high/.match?(attempt.raw)
end
|
#low ⇒ Object
82
83
84
|
# File 'lib/aoc_cli/solve.rb', line 82
def low
/too low/.match?(attempt.raw)
end
|
#react ⇒ Object
64
65
66
67
68
|
# File 'lib/aoc_cli/solve.rb', line 64
def react
Database::Attempt
.new(attempt:attempt)
.incorrect(high:high, low:low)
end
|
#respond ⇒ Object
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/aoc_cli/solve.rb', line 69
def respond
puts <<~response
#{"Incorrect".red.bold}: You guessed - #{attempt
.answer.to_s.red} #{
high ? "(too high)" :
low ? "(too low)" : ""}
#{"Please wait".yellow} #{wait_time} before answering again
response
self
end
|
#wait_time ⇒ Object
85
86
87
88
|
# File 'lib/aoc_cli/solve.rb', line 85
def wait_time
attempt.raw.scan(/(?:(one minute|\d+ minutes))/)
.first.first.to_s
end
|