Ruby Script

Go to Product
Executes a jRuby script, taking 1 input DataTable and returning 1 output DataTable. A simple example script is included in the dialog's text window of the Script tab.

This node uses a Ruby-wrapper. See knime.rb at ruby4knime

Also, you can include additional gems from an external jRuby installation. But before that do setup jRuby path in preferences.

Options

Script output

Append columns to input table spec
If checked, the columns as given in the list are appended to the input table specification. The number of columns in the output table equals the number of input columns plus the number of columns as given in the list. If unchecked, the output table will have exactly the same number of columns as given in the list.
Column list
Specify the column name and type of all result columns. After adding a new column, click on the name or type to change its value.

Script

$in_data_0
The input DataTable containing all available input from input port 0.
$out_data_0
Output container housing the outgoing DataTable for output port 0. This must be populated with rows by the script or else there will be no output from the node.
Example use to copy all input row of DataTable:
  $in_data_0.each do |row|
    $out_data_0 << row
  end
Example use to extend input rows by new columns:
  count = $in_data_0.length
  $in_data_0.each_with_index do |row, i|
    $out_data_0 << (row << Cells.new.string('Hi!').int(row.getCell(0).to_s.length))
    setProgress "#{i*100/count}%" if i%100 != 0
  end
Example use to create new DataTable from custom data:
  $in_data_0.each do |row|
    $out_data_0 << Cells.new.string(row[0].to_s.length.to_s)
  end

Input Ports

Icon
Table that the Ruby script will operate on.

Output Ports

Icon
Table containing the results of the Ruby script.

Views

This node has no views

Workflows

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.