Class: Box

Inherits:
Container show all
Defined in:
lib/sudoku_solver/box.rb

Instance Attribute Summary collapse

Attributes inherited from Container

#arr, #remaining_blocks

Instance Method Summary collapse

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

#boxObject

Returns the value of attribute box.



4
5
6
# File 'lib/sudoku_solver/box.rb', line 4

def box
  @box
end

#positionObject

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_spacesObject



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