Skip to content

Commit 2ddb3a6

Browse files
committed
updated code of example
1 parent 2e87bb4 commit 2ddb3a6

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Ruby scripting extension for [KNIME](http://knime.org)
77
This is preliminary support of Ruby scripting language for Knime.
88

99
Now realized following node types:
10+
1011
* Ruby Generator allows to generate any string or numeric data. Or process any external sources using Ruby.
1112
* Ruby Script allows to process input DataTable into output DataTable.
1213
* Ruby Script 2x2 allows to process 2 input DataTable into 2 output DataTable.
@@ -31,30 +32,39 @@ This is simple workflow for ruby4knime testing only. It includes all realized no
3132
Now some details.
3233

3334
Node 1 contains the following code:
35+
3436
```ruby
35-
1000.times do |i|
36-
x = i * 0.1 / Math::PI
37-
$outContainer << Cells.new.double(x).double(Math.sin(x)).double(Math.sin(x + Math::PI/3))
37+
0.step(6*Math::PI, 0.01) do |x|
38+
$outContainer << Cells.new.double(x).
39+
double(Math.sin(x)).
40+
double(Math.sin(x + Math::PI/3))
3841
end
3942
```
4043

4144
Node 2 contains the following code:
45+
4246
```ruby
4347
$outContainer.rowKey = 100000 # generate table keys from this number
44-
1000.times do |i|
45-
x = i * 0.1 / Math::PI
46-
$outContainer << Cells.new.double(x).double(Math.cos(x)).double(Math.cos(0.3*x))
48+
0.step(6*Math::PI, 0.01) do |x|
49+
$outContainer << Cells.new.double(x).
50+
double(Math.cos(x)).
51+
double(Math.cos(0.3 * x))
4752
end
4853
```
4954

5055
Node 3 contains the following code:
56+
5157
```ruby
5258
$inData0.each do |row|
53-
$outContainer << (row << Cells.new.double(row[1].to_f-row[2].to_f))
59+
$outContainer << (row << Cells.new.double(row.y1.to_f-row.y2.to_f))
60+
61+
# alternative
62+
# $outContainer << (row << Cells.new.double(row[1].to_f-row[2].to_f))
5463
end
5564
```
5665

5766
Node 4 contains the following code:
67+
5868
```ruby
5969
$inData0.each do |row|
6070
$outContainer0 << row
@@ -65,10 +75,14 @@ end
6575
```
6676

6777
Node 6 contains the following code:
78+
6879
```ruby
69-
Cells.new.
70-
double(row[1].to_f).
71-
double(row[2].to_f - row[4].to_f)
80+
Cells.new.double(row.y1.to_f).
81+
double(row.y2.to_f - row.y2_1.to_f)
82+
83+
# alternative
84+
# Cells.new.double(row[1].to_f).
85+
# double(row[2].to_f - row[4].to_f)
7286
```
7387

7488
Joiner (Node 5) generates following data:

0 commit comments

Comments
 (0)