Skip to content

Commit 0141faa

Browse files
committed
knime.rb style updates
1 parent 1e29531 commit 0141faa

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

RubyScript/rb/knime.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# coding: utf-8
1+
# frozen_string_literal: true
2+
23
require 'java'
34

45
java_import org.knime.base.data.append.column.AppendedColumnRow
@@ -21,7 +22,6 @@
2122
# for convinient Ruby script writing for KNIME
2223
# See also https://tech.knime.org/javadoc-api
2324
module Knime
24-
2525
private # hide methods from subclasses of Object class
2626

2727
# This module defines a container for columns for using it in
@@ -57,7 +57,7 @@ def add_cell(cell)
5757
add_cell rb_cls.new(val)
5858
self
5959
end
60-
end
60+
end
6161
end
6262

6363
# Instances of this class are intended for a columns container.
@@ -105,7 +105,7 @@ def [](idx)
105105
# Generate dynamic methods for accessing to cells by column name
106106
# from BlobSupportDataRow.
107107
# 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.
109109
# For input 0 only is generated simple names. For all inputs methods has
110110
# a following format: i#{input_num}_translated_column_name
111111
#
@@ -114,7 +114,7 @@ def [](idx)
114114
table = $input_datatable_arr[i]
115115
col_names = table.getDataTableSpec.getColumnNames.map do |str|
116116
[(s1 = str.gsub(/[^[[:word:]]]/, '_').gsub(/\_+/, '_').chomp('_')),
117-
s1.downcase].uniq
117+
s1.downcase].uniq
118118
end
119119
col_names.each_with_index do |names, num|
120120
names.each do |name|
@@ -155,13 +155,14 @@ def self.[]=(name, val)
155155
end
156156

157157
def snippet_runner
158-
count, step = $in_data_0.length, 0x2FF
158+
count = $in_data_0.length
159+
step = 0x2FF
159160
coef = step / count.to_f
160161
$in_data_0.each_with_index do |row, i|
161162
$out_data_0 << (yield row)
162163
setProgress "#{i * coef}%" if (i & step) == 0
163164
end
164-
end
165+
end
165166
end
166167

167168
include Knime
@@ -193,7 +194,7 @@ def length
193194
getRowCount
194195
end
195196

196-
alias_method :size, :length
197+
alias size length
197198
end
198199

199200
# Extended knime class
@@ -215,7 +216,7 @@ class DataContainer
215216
# Add row in the data container.
216217
# Row can be copied from input data container or created.
217218
def <<(obj)
218-
row = obj.kind_of?(Cells) ? createRowKey.new_row(obj) : obj
219+
row = obj.is_a?(Cells) ? createRowKey.new_row(obj) : obj
219220

220221
addRowToTable row
221222
end
@@ -229,7 +230,8 @@ def rowKey=(num)
229230
# Return RowKey object
230231
def createRowKey
231232
@key ||= 0
232-
key, @key = @key, @key + 1
233+
key = @key
234+
@key += 1
233235
RowKey.createRowKey key
234236
end
235237
end

0 commit comments

Comments
 (0)