Class: Dis::Layers

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/dis/layers.rb

Overview

Dis Layers

Represents a collection of layers.

Instance Method Summary collapse

Constructor Details

#initialize(layers = []) ⇒ Layers


10
11
12
# File 'lib/dis/layers.rb', line 10

def initialize(layers=[])
  @layers = layers
end

Instance Method Details

#<<(layer) ⇒ Object

Adds a layer to the collection.


15
16
17
# File 'lib/dis/layers.rb', line 15

def <<(layer)
  @layers << layer
end

#clear!Object

Clears all layers from the collection.


20
21
22
# File 'lib/dis/layers.rb', line 20

def clear!
  @layers = []
end

#delayedObject

Returns a new instance containing only the delayed layers.


30
31
32
# File 'lib/dis/layers.rb', line 30

def delayed
  self.class.new select { |layer| layer.delayed? }
end

#delayed?Boolean

Returns true if one or more delayed layers exist.


35
36
37
# File 'lib/dis/layers.rb', line 35

def delayed?
  delayed.any?
end

#eachObject

Iterates over the layers.


25
26
27
# File 'lib/dis/layers.rb', line 25

def each
  @layers.each { |layer| yield layer }
end

#immediateObject

Returns a new instance containing only the immediate layers.


40
41
42
# File 'lib/dis/layers.rb', line 40

def immediate
  self.class.new select { |layer| layer.immediate? }
end

#immediate?Boolean

Returns true if one or more immediate layers exist.


45
46
47
# File 'lib/dis/layers.rb', line 45

def immediate?
  immediate.any?
end

#readonlyObject

Returns a new instance containing only the readonly layers.


50
51
52
# File 'lib/dis/layers.rb', line 50

def readonly
  self.class.new select { |layer| layer.readonly? }
end

#readonly?Boolean

Returns true if one or more readonly layers exist.


55
56
57
# File 'lib/dis/layers.rb', line 55

def readonly?
  readonly.any?
end

#writeableObject

Returns a new instance containing only the writeable layers.


60
61
62
# File 'lib/dis/layers.rb', line 60

def writeable
  self.class.new select { |layer| layer.writeable? }
end

#writeable?Boolean

Returns true if one or more writeable layers exist.


65
66
67
# File 'lib/dis/layers.rb', line 65

def writeable?
  writeable.any?
end