Method: Grid#each_with_index

Defined in:
lib/cem/cruzzles.rb

#each_with_index(&block) ⇒ Object



511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/cem/cruzzles.rb', line 511

def each_with_index(&block)    
  case block.arity
    when 2 
      @data.each_with_index { |l, y|
          l.each_with_index { |c, x|
            block.call(c, Point2D.new(x,y))
          }
        }
    
    when 3      
      @data.each_with_index { |l, y|
          l.each_with_index { |c, x|
            block.call(c, y, x)
          }
        }
    else
      raise
  end
end