4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/string_as_key_combo/controllers/main_controller.rb', line 4
def keys(plus_separated_key_combination_string)
combo = plus_separated_key_combination_string
if combo.nil?
[]
else
inner_plus_subbed = combo.gsub(/\+\s*\+\s*\+/,'+plus+')
edge_plus_subbed = inner_plus_subbed.
sub(/^\s*\+\s*\+/,'plus+').
sub(/\+\s*\+\s*$/,'+plus')
strokes = edge_plus_subbed.split(/\s*\+\s*/)
plus_translated_strokes = strokes.map { |k| k == 'plus' ? '+' : k }
plus_translated_strokes.reject { |k| k.strip == '' }
end
end
|