Class: AocCli::Solve::Respond::Incorrect

Inherits:
Response
  • Object
show all
Defined in:
lib/aoc_cli/solve.rb

Instance Attribute Summary

Attributes inherited from Response

#attempt

Instance Method Summary collapse

Methods inherited from Response

#initialize

Constructor Details

This class inherits a constructor from AocCli::Solve::Respond::Response

Instance Method Details

#highObject



79
80
81
# File 'lib/aoc_cli/solve.rb', line 79

def high
	/too high/.match?(attempt.raw)
end

#lowObject



82
83
84
# File 'lib/aoc_cli/solve.rb', line 82

def low
	/too low/.match?(attempt.raw)
end

#reactObject



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

#respondObject



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_timeObject



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