Class: Rudoku::Block

Inherits:
Area
  • Object
show all
Defined in:
lib/rudoku.rb

Instance Attribute Summary collapse

Attributes inherited from Area

#board

Instance Method Summary collapse

Methods inherited from Area

#add, #available_nrs, #info, #missing_fields, #remove

Constructor Details

#initialize(b, n) ⇒ Block

Returns a new instance of Block.



331
332
333
334
335
336
# File 'lib/rudoku.rb', line 331

def initialize(b, n)
  @n = n
  @x = n % 3
  @y = n / 3
  super
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



329
330
331
# File 'lib/rudoku.rb', line 329

def fields
  @fields
end

Instance Method Details

#initialize_areaObject



338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/rudoku.rb', line 338

def initialize_area
  f_x = @x * 3
  f_y = @y * 3

  @fields = []

  f_y.upto(f_y + 2) do |y|
    f_x.upto(f_x + 2) do |x|
      @fields << board.get(x, y)
    end
  end
end