class Banzai::Pipeline

Pipeline is a filter that accepts an array of filters that will be applied to input sequentially.

@example Create a pipeline and process input

Pipeline.new(GaussianBlur.new(radius:1.1), Nostalgia).call(image)

Public Class Methods

new(*filters) click to toggle source

@param [Array<Filter>] filters array of filters that will be in the

pipeline. They can be either Filter class or instance.
# File lib/banzai/pipeline.rb, line 13
def initialize(*filters)
  @filters = filters.flatten
end

Public Instance Methods

call(input) click to toggle source

Process input by sending it down the filters pipeline

@param [Object] input @return [Object]

# File lib/banzai/pipeline.rb, line 21
def call(input)
  @filters.inject(input) do |content, filter|
    filter.call(content)
  end
end