Class: Dis::Layers
Overview
Dis Layers
Represents a filterable collection of Layer instances. Supports chained filtering by layer properties.
Instance Method Summary collapse
-
#cache ⇒ Dis::Layers
Returns a new instance containing only the cache layers.
-
#cache? ⇒ Boolean
Returns true if one or more cache layers exist.
-
#clear! ⇒ void
Clears all layers from the collection.
-
#delayed ⇒ Dis::Layers
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 ⇒ Dis::Layers
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.
-
#non_cache ⇒ Dis::Layers
Returns a new instance containing only the non-cache layers.
-
#non_cache? ⇒ Boolean
Returns true if one or more non-cache layers exist.
-
#readonly ⇒ Dis::Layers
Returns a new instance containing only the readonly layers.
-
#readonly? ⇒ Boolean
Returns true if one or more readonly layers exist.
-
#writeable ⇒ Dis::Layers
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.
15 16 17 |
# File 'lib/dis/layers.rb', line 15 def initialize(layers = []) @layers = layers end |
Instance Method Details
#cache ⇒ Dis::Layers
Returns a new instance containing only the cache layers.
93 94 95 |
# File 'lib/dis/layers.rb', line 93 def cache self.class.new select(&:cache?) end |
#cache? ⇒ Boolean
Returns true if one or more cache layers exist.
100 101 102 |
# File 'lib/dis/layers.rb', line 100 def cache? any?(&:cache?) end |
#clear! ⇒ void
This method returns an undefined value.
Clears all layers from the collection.
25 26 27 |
# File 'lib/dis/layers.rb', line 25 def clear! @layers = [] end |
#delayed ⇒ Dis::Layers
Returns a new instance containing only the delayed layers.
37 38 39 |
# File 'lib/dis/layers.rb', line 37 def delayed self.class.new select(&:delayed?) end |
#delayed? ⇒ Boolean
Returns true if one or more delayed layers exist.
44 45 46 |
# File 'lib/dis/layers.rb', line 44 def delayed? any?(&:delayed?) end |
#each(&block) ⇒ Object
Iterates over the layers.
30 31 32 |
# File 'lib/dis/layers.rb', line 30 def each(&block) @layers.each { |layer| block.call(layer) } end |
#immediate ⇒ Dis::Layers
Returns a new instance containing only the immediate layers.
51 52 53 |
# File 'lib/dis/layers.rb', line 51 def immediate self.class.new select(&:immediate?) end |
#immediate? ⇒ Boolean
Returns true if one or more immediate layers exist.
58 59 60 |
# File 'lib/dis/layers.rb', line 58 def immediate? any?(&:immediate?) end |
#non_cache ⇒ Dis::Layers
Returns a new instance containing only the non-cache layers.
107 108 109 |
# File 'lib/dis/layers.rb', line 107 def non_cache self.class.new reject(&:cache?) end |
#non_cache? ⇒ Boolean
Returns true if one or more non-cache layers exist.
114 115 116 |
# File 'lib/dis/layers.rb', line 114 def non_cache? any? { |l| !l.cache? } end |
#readonly ⇒ Dis::Layers
Returns a new instance containing only the readonly layers.
65 66 67 |
# File 'lib/dis/layers.rb', line 65 def readonly self.class.new select(&:readonly?) end |
#readonly? ⇒ Boolean
Returns true if one or more readonly layers exist.
72 73 74 |
# File 'lib/dis/layers.rb', line 72 def readonly? any?(&:readonly?) end |
#writeable ⇒ Dis::Layers
Returns a new instance containing only the writeable layers.
79 80 81 |
# File 'lib/dis/layers.rb', line 79 def writeable self.class.new select(&:writeable?) end |
#writeable? ⇒ Boolean
Returns true if one or more writeable layers exist.
86 87 88 |
# File 'lib/dis/layers.rb', line 86 def writeable? any?(&:writeable?) end |