Class: Mapscript::LayerClasses

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

Overview

ClassObj iterator

Instance Method Summary collapse

Methods inherited from MapscriptEnumerable

#each, #size

Constructor Details

#initialize(layer) ⇒ LayerClasses

Returns a new instance of LayerClasses.



75
76
77
78
# File 'lib/mapscript/mapscript_extensions.rb', line 75

def initialize(layer)
  super(layer, :numclasses, :getClass)
  @layer = layer
end

Instance Method Details

#<<(newclass) ⇒ Object



97
98
99
# File 'lib/mapscript/mapscript_extensions.rb', line 97

def <<(newclass)
  @layer.insertClass(newclass, @layer.numclasses-1)
end

#[](idx) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/mapscript/mapscript_extensions.rb', line 80

def [](idx)
  case idx
    when Fixnum
      if idx >= 0
        @layer.getClass(idx)
      else
        @layer.getClass(@layer.numclasses+idx)
      end
    when Range
      to_a[idx]
    when String
      find { |cls| cls.name == idx }
    else
      raise TypeError, "Unsupported type for index"
  end
end