module Codebreaker::Console
Public Instance Methods
agree?()
click to toggle source
# File lib/codebreaker/modules/console.rb, line 24 def agree? input =~ /^(yes|y)$/i ? true : false end
input()
click to toggle source
# File lib/codebreaker/modules/console.rb, line 3 def input gets.chomp end
input_code()
click to toggle source
# File lib/codebreaker/modules/console.rb, line 12 def input_code puts "You have #{@game.attempts} attempts and #{@game.hint} hint." print 'Type your secret code or "hint": ' player_code = input if player_code =~ /^[1-6]{4}|hint$/ player_code else puts 'You should type 4 numbers in code or "hint"!!!' input_code end end
input_name()
click to toggle source
# File lib/codebreaker/modules/console.rb, line 7 def input_name print 'Please, enter your name: ' input end
new_game()
click to toggle source
# File lib/codebreaker/modules/console.rb, line 28 def new_game @game = Game.new(@game.score) if agree? end