Skip to content

Commit 761366c

Browse files
committed
ruby: now column names are translated both in downcased and normal name
1 parent db66cda commit 761366c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

RubyScript/rb/knime.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,23 @@ def [](idx)
104104

105105
# Generate dynamic methods for accessing to cells by column name
106106
# from BlobSupportDataRow.
107-
# All names are translated in low case. All symbols except :word: are
108-
# changed to underline symbol.
107+
# All symbols except :word: are changed to underline symbol.
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
#
112112
$num_inputs ||= 0
113113
(0...$num_inputs).each do |i|
114114
table = $input_datatable_arr[i]
115115
col_names = table.getDataTableSpec.getColumnNames.map do |str|
116-
str.downcase.gsub(/[^[[:word:]]]/, '_').gsub(/\_+/, '_').chomp('_')
116+
[(s1 = str.gsub(/[^[[:word:]]]/, '_').gsub(/\_+/, '_').chomp('_')),
117+
s1.downcase].uniq
117118
end
118-
col_names.each_with_index do |name, num|
119-
define_method(name) { getCell(num) } if i == 0
120-
define_method("i#{i}_#{name}") { getCell(num) }
119+
col_names.each_with_index do |names, num|
120+
names.each do |name|
121+
define_method(name) { getCell(num) } if i == 0
122+
define_method("i#{i}_#{name}") { getCell(num) }
123+
end
121124
end
122125
end
123126
end

0 commit comments

Comments
 (0)