Class: RubyGo::TextPrinter
- Inherits:
-
Object
- Object
- RubyGo::TextPrinter
- Defined in:
- lib/ruby-go/printers/text.rb
Constant Summary collapse
- COLORS =
{ black: 'x', white: 'o', empty: '_' }.freeze
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
-
#initialize(io) ⇒ TextPrinter
constructor
A new instance of TextPrinter.
- #print_game(game) ⇒ Object
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
#io ⇒ Object (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
#print_game(game) ⇒ Object
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 |