Sha256: 47f286427c0f2a5e65ba09b97f12be3069d895fcc7ef681f3fc97da1655dd52c
Contents?: true
Size: 428 Bytes
Versions: 4
Compression:
Stored size: 428 Bytes
Contents
module Input class Incorrect < StandardError; end def get_input(input_message, regex = nil, err_message = "Incorrect input, try again") begin print input_message input = gets.chomp if block_given? raise Input::Incorrect unless yield(input) else raise Input::Incorrect unless regex.match?(input) end rescue puts err_message retry end input end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
chess_engine-0.0.9 | lib/chess_engine/input.rb |
chess_engine-0.0.8 | lib/chess_engine/input.rb |
chess_engine-0.0.2 | lib/chess_engine/input.rb |
chess_engine-0.0.1 | lib/chess_engine/input.rb |