1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
require 'java'
3
4
4
5
java_import org . knime . base . data . append . column . AppendedColumnRow
21
22
# for convinient Ruby script writing for KNIME
22
23
# See also https://tech.knime.org/javadoc-api
23
24
module Knime
24
-
25
25
private # hide methods from subclasses of Object class
26
26
27
27
# This module defines a container for columns for using it in
@@ -57,7 +57,7 @@ def add_cell(cell)
57
57
add_cell rb_cls . new ( val )
58
58
self
59
59
end
60
- end
60
+ end
61
61
end
62
62
63
63
# Instances of this class are intended for a columns container.
@@ -105,7 +105,7 @@ def [](idx)
105
105
# Generate dynamic methods for accessing to cells by column name
106
106
# from BlobSupportDataRow.
107
107
# All symbols except :word: are changed to underline symbol.
108
- # For all names is created a pair of normal and downcased name.
108
+ # For all names is created a pair of normal and downcased name.
109
109
# For input 0 only is generated simple names. For all inputs methods has
110
110
# a following format: i#{input_num}_translated_column_name
111
111
#
@@ -114,7 +114,7 @@ def [](idx)
114
114
table = $input_datatable_arr[ i ]
115
115
col_names = table . getDataTableSpec . getColumnNames . map do |str |
116
116
[ ( s1 = str . gsub ( /[^[[:word:]]]/ , '_' ) . gsub ( /\_ +/ , '_' ) . chomp ( '_' ) ) ,
117
- s1 . downcase ] . uniq
117
+ s1 . downcase ] . uniq
118
118
end
119
119
col_names . each_with_index do |names , num |
120
120
names . each do |name |
@@ -155,13 +155,14 @@ def self.[]=(name, val)
155
155
end
156
156
157
157
def snippet_runner
158
- count , step = $in_data_0. length , 0x2FF
158
+ count = $in_data_0. length
159
+ step = 0x2FF
159
160
coef = step / count . to_f
160
161
$in_data_0. each_with_index do |row , i |
161
162
$out_data_0 << ( yield row )
162
163
setProgress "#{ i * coef } %" if ( i & step ) == 0
163
164
end
164
- end
165
+ end
165
166
end
166
167
167
168
include Knime
@@ -193,7 +194,7 @@ def length
193
194
getRowCount
194
195
end
195
196
196
- alias_method : size, : length
197
+ alias size length
197
198
end
198
199
199
200
# Extended knime class
@@ -215,7 +216,7 @@ class DataContainer
215
216
# Add row in the data container.
216
217
# Row can be copied from input data container or created.
217
218
def <<( obj )
218
- row = obj . kind_of ?( Cells ) ? createRowKey . new_row ( obj ) : obj
219
+ row = obj . is_a ?( Cells ) ? createRowKey . new_row ( obj ) : obj
219
220
220
221
addRowToTable row
221
222
end
@@ -229,7 +230,8 @@ def rowKey=(num)
229
230
# Return RowKey object
230
231
def createRowKey
231
232
@key ||= 0
232
- key , @key = @key , @key + 1
233
+ key = @key
234
+ @key += 1
233
235
RowKey . createRowKey key
234
236
end
235
237
end
0 commit comments