From 04e0a1fd3d43013d603092e09ac827b022cba3b9 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Tue, 22 Sep 2020 15:57:09 -0500 Subject: Change command tag template arguments to: VARIABLE_NAME INDEX SUBSTRING_START SUBSTRING_END --- app/lib/command_tag/processor.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/lib/command_tag/processor.rb b/app/lib/command_tag/processor.rb index 8461e902f..6bc9a9b97 100644 --- a/app/lib/command_tag/processor.rb +++ b/app/lib/command_tag/processor.rb @@ -137,16 +137,15 @@ class CommandTag::Processor end end - index_start = to_integer(parts[1]) - index_end = to_integer(parts[2]) + index = to_integer(parts[1]) + str_start = to_integer(parts[2]) + str_end = to_integer(parts[3]) - if ['all', '[]'].include?(parts[1]) - var(name).join(separator) - elsif index_end.zero? - var(name)[index_start].presence || '' - else - var(name)[index_start..index_end].presence || '' - end + str_start, str_end = [str_end, str_start] if str_start > str_end + + value = (['all', '[]'].include?(parts[1]) ? var(name).join(separator) : var(name)[index].to_s) + + (str_end - str_start).zero? ? value : value[str_start..str_end] end end.rstrip end -- cgit