class MastermindSname::Command
Attributes
game_colours[RW]
guesses[RW]
Public Class Methods
new()
click to toggle source
# File lib/mastermind_sname/sname/command.rb, line 5 def initialize @game_colours = game_colours end
Public Instance Methods
action(guess, game_colours, guesses)
click to toggle source
# File lib/mastermind_sname/sname/command.rb, line 9 def action(guess, game_colours, guesses) @game_colours = game_colours @guesses = guesses case guess when "quit", "q" then exit when "cheat", "c" then cheat_mode when "h", "history" then get_history end end
cheat_mode()
click to toggle source
# File lib/mastermind_sname/sname/command.rb, line 19 def cheat_mode puts Message.new.cheat(@game_colours) exit end
get_history()
click to toggle source
# File lib/mastermind_sname/sname/command.rb, line 24 def get_history return "No guesses yet" if @guesses.empty? @guesses.each_with_index\ { |val, i| print " #{i + 1} ==> #{val} \n" } print "\n" puts "Enter guess" end