Class: Mapscript::MapLayers

Inherits:
MapscriptEnumerable show all
Defined in:
lib/mapscript/mapscript_extensions.rb

Overview

LayerObj iterator

Instance Method Summary collapse

Methods inherited from MapscriptEnumerable

#each, #size

Constructor Details

#initialize(map) ⇒ MapLayers

Returns a new instance of MapLayers.



45
46
47
48
# File 'lib/mapscript/mapscript_extensions.rb', line 45

def initialize(map)
  super(map, :numlayers, :getLayer)
  @map = map
end

Instance Method Details

#<<(layer) ⇒ Object



67
68
69
# File 'lib/mapscript/mapscript_extensions.rb', line 67

def <<(layer)
  @map.insertLayer(layer, @map.numlayers-1)
end

#[](idx) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/mapscript/mapscript_extensions.rb', line 50

def [](idx)
  case idx
    when Fixnum
      if idx >= 0
        @map.getLayer(idx)
      else
        @map.getLayer(@map.numlayers+idx)
      end
    when Range
      to_a[idx]
    when String
      @map.getLayerByName(idx)
    else
      raise TypeError, "Unsupported type for index"
  end
end