class Mastermind::CLI
Attributes
command[RW]
game[R]
instream[R]
interact[R]
outstream[R]
Public Class Methods
new(instream, outstream)
click to toggle source
# File lib/mastermind/cli.rb, line 8 def initialize(instream, outstream) @instream = instream @outstream = outstream @command = "" @interact = Mastermind::Interact.new end
Public Instance Methods
get_command()
click to toggle source
# File lib/mastermind/cli.rb, line 25 def get_command outstream.print interact.command_prompt self.command = instream.gets.strip.upcase end
instructions?()
click to toggle source
# File lib/mastermind/cli.rb, line 47 def instructions? command == 'I' || command == 'INSTRUCTIONS' end
play?()
click to toggle source
# File lib/mastermind/cli.rb, line 43 def play? command == 'P' || command == 'PLAY' end
process_command()
click to toggle source
# File lib/mastermind/cli.rb, line 30 def process_command case when quit? then outstream.puts interact.print_farewell when instructions? then outstream.puts interact.print_instructions(Mastermind.color_option_string(6)) when play? then Mastermind::PlayGame.new(instream, outstream, interact).run else outstream.puts interact.print_invalid(command) end end
quit?()
click to toggle source
# File lib/mastermind/cli.rb, line 39 def quit? command == 'Q' || command == 'QUIT' end
run()
click to toggle source
# File lib/mastermind/cli.rb, line 15 def run outstream.puts interact.screen_clear outstream.puts interact.print_title outstream.puts interact.print_intro until quit? get_command process_command end end