Module: ConnectFour::Display
- Included in:
- Board
- Defined in:
- lib/connect_four/display.rb
Overview
console display
Instance Method Summary collapse
Instance Method Details
#board_string ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/connect_four/display.rb', line 15 def board_string string = +'' 5.downto(0) do |index| @data.each_value do |elem| node = elem.at(index) data = node.data unless node.nil? string << " #{data || ' '} │" end string << "\n" end string end |
#display_board ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/connect_four/display.rb', line 7 def display_board string = board_string # draw board_string puts "\n\n#{string}" # index values puts " 1 2 3 4 5 6 7\n\n" end |
#redraw ⇒ Object
28 29 30 31 |
# File 'lib/connect_four/display.rb', line 28 def redraw print "\e[11F" display_board end |