Class: Itiel::Script::RubyScript

Inherits:
Object
  • Object
show all
Includes:
ChainedStep
Defined in:
lib/itiel/script/ruby_script.rb

Overview

Process the stream with ruby

Initialize it with a block that will yield each row of the stream.

Usage:

Itiel::Script::RubyScript.new do |row|
  row["slug"] = row["title"]
end

Instance Attribute Summary collapse

Attributes included from ChainedStep

#next_step

Instance Method Summary collapse

Methods included from ChainedStep

#input=

Constructor Details

#initialize(&block) ⇒ RubyScript

Returns a new instance of RubyScript.



19
20
21
# File 'lib/itiel/script/ruby_script.rb', line 19

def initialize(&block)
  self.block = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



17
18
19
# File 'lib/itiel/script/ruby_script.rb', line 17

def block
  @block
end

Instance Method Details

#execute(input_stream) ⇒ Object



23
24
25
26
27
# File 'lib/itiel/script/ruby_script.rb', line 23

def execute(input_stream)
  input_stream.each do |row|
    block.call(row)
  end
end