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

Returns a new instance of 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(&:delayed?)
end

#delayed?Boolean

Returns true if one or more delayed layers exist.

Returns:

  • (Boolean)


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

def delayed?
  delayed.any?
end

#each(&block) ⇒ Object

Iterates over the layers.



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

def each(&block)
  @layers.each { |layer| block.call(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(&:immediate?)
end

#immediate?Boolean

Returns true if one or more immediate layers exist.

Returns:

  • (Boolean)


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(&:readonly?)
end

#readonly?Boolean

Returns true if one or more readonly layers exist.

Returns:

  • (Boolean)


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(&:writeable?)
end

#writeable?Boolean

Returns true if one or more writeable layers exist.

Returns:

  • (Boolean)


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

def writeable?
  writeable.any?
end