class ProcBuffer

TODO: Documentation ProcBuffer

Constants

VERSION

Public Class Methods

new(*actions) click to toggle source
# File lib/proc_buffer.rb, line 8
def initialize(*actions)
  # For now we will not handle actions that do not respond to #call
  @actions = actions.select { |action| action.respond_to?(:call) }
end

Public Instance Methods

actions() click to toggle source
# File lib/proc_buffer.rb, line 13
def actions
  @actions.dup
end
append(&block) click to toggle source
# File lib/proc_buffer.rb, line 29
def append(&block)
  @actions << block
end
Also aliased as: push
each() { |action| ... } click to toggle source
# File lib/proc_buffer.rb, line 17
def each
  @actions.each { |action| yield action }
end
pop(n = nil) click to toggle source
# File lib/proc_buffer.rb, line 35
def pop(n = nil)
  return @actions.pop.call unless n
  (1..n).map { @actions.pop.call }
end
push(&block)
Alias for: append
reverse_run() click to toggle source
# File lib/proc_buffer.rb, line 25
def reverse_run
  @actions.reverse.map { |action| call(action) }
end
run() click to toggle source
# File lib/proc_buffer.rb, line 21
def run
  map(&:call)
end