Class: RubyGo::TextPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-go/printers/text.rb

Constant Summary collapse

COLORS =
{ black: 'x', white: 'o', empty: '_' }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ TextPrinter

Returns a new instance of TextPrinter.



7
8
9
# File 'lib/ruby-go/printers/text.rb', line 7

def initialize(io)
  @io = io
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



5
6
7
# File 'lib/ruby-go/printers/text.rb', line 5

def io
  @io
end

Instance Method Details



11
12
13
14
15
16
17
# File 'lib/ruby-go/printers/text.rb', line 11

def print_game(game)
  print_board(game.board)
  io.puts  "   " + "_"*(game.board.size * 2)
  io.print "   Prisoners || White: #{game.captures[:black]} |"
  io.puts  " Black: #{game.captures[:white]}"
  io.puts  "   " + "-"*(game.board.size * 2)
end