class TurtleGame::Commands::Turtle
Attributes
move_input[RW]
Public Class Methods
new(width, options)
click to toggle source
# File lib/turtle_game/commands/turtle.rb, line 12 def initialize(width, options) @width = width @options = options end
Public Instance Methods
execute(input: $stdin, output: $stdout)
click to toggle source
# File lib/turtle_game/commands/turtle.rb, line 17 def execute(input: $stdin, output: $stdout) put_instructions(output) game = TurtleGame::Game.new(@width, output) loop do move_input = TTY::Reader.new.read_char break if move_input == 'x' game.move(move_input) end output.puts 'Thanks for playing' end
Private Instance Methods
put_instructions(output)
click to toggle source
# File lib/turtle_game/commands/turtle.rb, line 30 def put_instructions(output) output.puts <<~INSTRUCTIONS Use WASD to move your tutle Use X to exit INSTRUCTIONS end