class AgwxGrids::GridLayer

Attributes

rows[R]
zIndex[RW]

Public Class Methods

new(gridFile,metaData) click to toggle source
# File lib/agwx_grids/grid.rb, line 99
def initialize(gridFile,metaData)
  @zIndex = gridFile.gets.scan(/\d+/)[0].to_i
  @rows = Array.new
  for row in 0...metaData.yDim
    @rows[row] = gridFile.gets.scan(/-*\d+.\d+/).collect {|s| s.to_f }
  end
end

Public Instance Methods

<=>(aLayer) click to toggle source

compare two layers (based on zIndex)

# File lib/agwx_grids/grid.rb, line 122
def <=>(aLayer)
  if @zIndex < aLayer.zIndex then
      return -1
  elsif @zIndex == aLayer.zIndex then
      return 0
  else
      return 1
  end
end
get(x,y) click to toggle source

return value for x-y posn (x and y in tuple space, not “real” space)

# File lib/agwx_grids/grid.rb, line 112
def get(x,y)
  row = @rows[y]
  if row == nil
      nil
  else
    # puts "GLayer.get got a row: #{row.inspect} and the value is #{row[x]}"
    row[x]
  end
end
row(y) click to toggle source
# File lib/agwx_grids/grid.rb, line 132
def row(y)
  @rows[y]
end
to_s() click to toggle source
# File lib/agwx_grids/grid.rb, line 106
def to_s
  row0 = @rows[0]
  row0Length = row0.length
  "zIndex: #{@zIndex} num rows: #{@rows.length} num cols: #{row0Length}\n row 0: #{@rows[0]}"
end