Class: Dis::Layers
Overview
Dis Layers
Represents a collection of layers.
Instance Method Summary collapse
-
#<<(layer) ⇒ Object
Adds a layer to the collection.
-
#clear! ⇒ Object
Clears all layers from the collection.
-
#delayed ⇒ Object
Returns a new instance containing only the delayed layers.
-
#delayed? ⇒ Boolean
Returns true if one or more delayed layers exist.
-
#each(&block) ⇒ Object
Iterates over the layers.
-
#immediate ⇒ Object
Returns a new instance containing only the immediate layers.
-
#immediate? ⇒ Boolean
Returns true if one or more immediate layers exist.
-
#initialize(layers = []) ⇒ Layers
constructor
A new instance of Layers.
-
#readonly ⇒ Object
Returns a new instance containing only the readonly layers.
-
#readonly? ⇒ Boolean
Returns true if one or more readonly layers exist.
-
#writeable ⇒ Object
Returns a new instance containing only the writeable layers.
-
#writeable? ⇒ Boolean
Returns true if one or more writeable layers exist.
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 |
#delayed ⇒ Object
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.
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 |
#immediate ⇒ Object
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.
45 46 47 |
# File 'lib/dis/layers.rb', line 45 def immediate? immediate.any? end |
#readonly ⇒ Object
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.
55 56 57 |
# File 'lib/dis/layers.rb', line 55 def readonly? readonly.any? end |
#writeable ⇒ Object
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.
65 66 67 |
# File 'lib/dis/layers.rb', line 65 def writeable? writeable.any? end |