class Shrek::Layers

Attributes

next_layer[R]

Public Class Methods

new(next_layer_proc = nil) click to toggle source
# File lib/shrek/layers.rb, line 5
def initialize(next_layer_proc = nil)
  next_layer_proc ||= EMPTY_RETURN
  @next_layer = next_layer_proc
end

Public Instance Methods

call(*) click to toggle source
# File lib/shrek/layers.rb, line 10
def call(*)
  raise 'Layer subclasses must define #call'
end
skip(count = 1) click to toggle source
# File lib/shrek/layers.rb, line 19
def skip(count = 1)
  skip! count
rescue NoMethodError => _error
  EMPTY_RETURN
end
skip!(count = 1) click to toggle source
# File lib/shrek/layers.rb, line 14
def skip!(count = 1)
  raise ArgumentError unless count.is_a?(Integer) || count <= 0
  count.times.inject(self) { |acc, _| acc.next_layer }
end