Class: Box
Instance Attribute Summary collapse
-
#box ⇒ Object
Returns the value of attribute box.
-
#position ⇒ Object
Returns the value of attribute position.
Attributes inherited from Container
Instance Method Summary collapse
- #blank_spaces ⇒ Object
-
#initialize(arr, y = 0, x = 0) ⇒ Box
constructor
A new instance of Box.
Methods inherited from Container
#complete, #contain?, #difference, #pencil_in, #remaining
Constructor Details
#initialize(arr, y = 0, x = 0) ⇒ Box
Returns a new instance of Box.
6 7 8 9 10 |
# File 'lib/sudoku_solver/box.rb', line 6 def initialize(arr, y=0, x=0) super(arr) Struct.new("Coordinate", :x, :y) if !Struct::const_defined? "Coordinate" @position = Struct::Coordinate.new(x, y) end |
Instance Attribute Details
#box ⇒ Object
Returns the value of attribute box.
4 5 6 |
# File 'lib/sudoku_solver/box.rb', line 4 def box @box end |
#position ⇒ Object
Returns the value of attribute position.
4 5 6 |
# File 'lib/sudoku_solver/box.rb', line 4 def position @position end |
Instance Method Details
#blank_spaces ⇒ Object
12 13 14 |
# File 'lib/sudoku_solver/box.rb', line 12 def blank_spaces [(position.y / 3) * 3 + (position.x / 3), position.y, position.x] end |