Skip to content

Commit 8344d9d

Browse files
committed
updated rdoc examples
1 parent 4ac6caf commit 8344d9d

1 file changed

Lines changed: 42 additions & 26 deletions

File tree

RubyScript/rb/README.rdoc

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,63 @@
11
= Ruby4Knime
22

3-
Ruby4Knime is a realization of special node types for http://knime.org that allow to use Ruby scripts for interactive data analytic.
3+
Ruby4Knime is a realization of special node types for
4+
http://knime.org that allow to use Ruby scripts for
5+
interactive data analytic.
6+
47
The main aims of this project are:
58
* provide possibility to use Ruby language for interactive data analysis;
69
* make the analysis more effective using clear and laconic Ruby style.
710

8-
knime.rb is the simple mediator that allows to use KNIME`s classes written in Java in the Ruby programming style and also use all Java classes without any changes.
11+
knime.rb is the simple mediator that allows to use KNIME`s classes
12+
written in Java in the Ruby programming style and also use all
13+
Java classes without any changes.
914

1015
= Simple examples
11-
These samples illustrate how to generate output data from input data of the node.
16+
These samples illustrate how to generate output data from input
17+
data of the node.
1218

1319
== Copy existing rows
1420

15-
$inData0.each do |row|
16-
$outContainer << row
21+
$in_data_0.each do |row|
22+
$out_data_0 << row
1723
end
1824

1925
== Add new two columns with String and Int types
2026
This example also illustrates the progress state updating.
2127

22-
count = $inData0.length
23-
$inData0.each_with_index do |row, i|
24-
$outContainer << (row << Cells.new.string('Hi!').int(row.getCell(0).to_s.length))
28+
table = $input_datatable_arr[0]
29+
count = table.length
30+
table.each_with_index do |row, i|
31+
$out_data_0 << (row << Cells.new.string('Hi!').
32+
int(row[0].to_s.length))
33+
2534
setProgress "#{i*100/count}%" if i%100 != 0
2635
end
2736

2837
== Create new rows
29-
In this example new rows creates with new uniq rowkeys. Therefore it is possible to create output table with any number of rows.
30-
$inData0.each do |row|
31-
$outContainer << Cells.new.string(row.getCell(0).to_s.length.to_s)
38+
In this example new rows creates with new uniq rowkeys.
39+
Therefore it is possible to create output table with any number of rows.
40+
$in_data_0.each do |row|
41+
$out_data_0 << Cells.new.string( row.getCell(0).to_s.length.to_s )
3242
end
3343

34-
In this example cell 0 copies without changes and adds difference between cells with indexes 1 and 2. Index in Ruby style.
35-
$inData0.each do |row|
36-
$outContainer << Cells.new.int(row[0].to_i).double(row[1].to_f - row[2].to_f)
44+
In this example cell 0 copies without changes and adds difference between
45+
cells with indexes 1 and 2. Index in Ruby style.
46+
47+
$in_data_0.each do |row|
48+
$out_data_0 << Cells.new.int(row[0].to_i).
49+
double(row[1].to_f - row[2].to_f)
3750
end
3851

3952

4053
== Ruby Snippet examples
41-
Ruby snippet realizes as the body of a lambda-function in the following template:
54+
Ruby snippet realizes as the body of a lambda-function
55+
in the following template:
56+
4257
func = ->(row) do
4358
<<SNIPPET CODE>>
4459
end
45-
snippetRunner &func
60+
snippet_runner &func
4661

4762
=== Simple snippet examples
4863
Copy all rows without changes. Code may contains only row-variable.
@@ -70,25 +85,26 @@ BlobSupportDataRow class. Following code fragments are available:
7085

7186
and
7287

73-
$inData0.each do |row|
74-
$outContainer << Cells.new.string(row.x.to_s)
88+
$in_data_0.each do |row|
89+
$out_data_0 << Cells.new.string(row.x.to_s)
7590
end
7691

7792
== Other experiments
7893
Samples that add new cells in functional style.
79-
count = $inData0.length
80-
$inData0.each_with_index do |row,i|
81-
$outContainer << row.string('Hi!').int(row.getCell(0).to_s.length).append
94+
count = $in_data_0.length
95+
$in_data_0.each_with_index do |row,i|
96+
$out_data_0 << row.string('Hi!').int(row.getCell(0).to_s.length).append
8297
setProgress "#{i*100/count}%" if i%100 != 0
8398
end
84-
85-
$inData0.each do |row|
86-
$outContainer << $outContainer.createRowKey.stringCell(row.getCell(0).to_s.length.to_s).new_row
99+
-
100+
$in_data_0.each do |row|
101+
$out_data_0 << $out_data_0.createRowKey.
102+
stringCell(row.getCell(0).to_s.length.to_s).new_row
87103
end
88104

89105
= Other notes
90106

91107
Now it is possible to use any types of KNIME in the DataOutput table.
92108
Simply input a full qualified Java class name in the configuration dialog of
93-
the Ruby node. E.g. org.knime.core.data.def.ComplexNumberCell or
94-
org.knime.ext.textprocessing.data.DocumentCell.
109+
the Ruby node. E.g. org.knime.core.data.def.ComplexNumberCell or
110+
org.knime.ext.textprocessing.data.DocumentCell.

0 commit comments

Comments
 (0)