Class: Turbine::Pipeline::Transform

Inherits:
Segment
  • Object
show all
Defined in:
lib/turbine/pipeline/transform.rb

Overview

A segment which transforms the input into something else. For example, a simple transform might receive an integer and output it’s square root.

Transform.new { |x| Math.sqrt(x) }

Instance Attribute Summary

Attributes inherited from Segment

#source

Instance Method Summary collapse

Methods inherited from Segment

#append, #each, #inspect, #next, #rewind, #to_s, #trace, #tracing=

Constructor Details

#initialize(&block) ⇒ Transform

Public: Creates a new Transform element.

You may opt to use the Transform class directly, passing a block when initializing which is used to transform each value into something else. Alternatively, provide no block and use a subclass with a custom transform method.

Without a filter block, all elements are emitted.

block - An optional block used to transform each value passing through

the pipeline into something else.

Returns a transform.



22
23
24
25
# File 'lib/turbine/pipeline/transform.rb', line 22

def initialize(&block)
  @transform = (block || method(:transform))
  super()
end