Class: Xudoku::Formatter::String

Inherits:
Base
  • Object
show all
Defined in:
lib/xudoku/formatter/string.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Base

#board

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Xudoku::Formatter::Base

Instance Method Details

#formatObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/xudoku/formatter/string.rb', line 7

def format
  output = ""
  9.times do |row|
    9.times do |col|
      output << ["", " ", " ", "  ", " ", " ", "  ", " ", " "][col]

      value = board.value_at(row, col, Axis::ROW)

      output << (value.nil? ? "_" : (value + 1).to_s)
    end
    output << %W[\n \n \n\n \n \n \n\n \n \n \n][row]
  end

  output
end