Class: Dis::Layers

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

Overview

Dis Layers

Represents a filterable collection of Layer instances. Supports chained filtering by layer properties.

Examples:

Dis::Storage.layers.delayed.writeable.each { |l| ... }

Instance Method Summary collapse

Constructor Details

#initialize(layers = []) ⇒ Layers

Returns a new instance of Layers.

Parameters:

  • layers (Array<Dis::Layer>) (defaults to: [])

    initial layers



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

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

Instance Method Details

#cacheDis::Layers

Returns a new instance containing only the cache layers.

Returns:



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.

Returns:

  • (Boolean)


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

#delayedDis::Layers

Returns a new instance containing only the delayed layers.

Returns:



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.

Returns:

  • (Boolean)


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

#immediateDis::Layers

Returns a new instance containing only the immediate layers.

Returns:



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.

Returns:

  • (Boolean)


58
59
60
# File 'lib/dis/layers.rb', line 58

def immediate?
  any?(&:immediate?)
end

#non_cacheDis::Layers

Returns a new instance containing only the non-cache layers.

Returns:



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.

Returns:

  • (Boolean)


114
115
116
# File 'lib/dis/layers.rb', line 114

def non_cache?
  any? { |l| !l.cache? }
end

#readonlyDis::Layers

Returns a new instance containing only the readonly layers.

Returns:



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.

Returns:

  • (Boolean)


72
73
74
# File 'lib/dis/layers.rb', line 72

def readonly?
  any?(&:readonly?)
end

#writeableDis::Layers

Returns a new instance containing only the writeable layers.

Returns:



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.

Returns:

  • (Boolean)


86
87
88
# File 'lib/dis/layers.rb', line 86

def writeable?
  any?(&:writeable?)
end