diff options
Diffstat (limited to 'app/lib/command_tag/commands')
-rw-r--r-- | app/lib/command_tag/commands/variables.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/lib/command_tag/commands/variables.rb b/app/lib/command_tag/commands/variables.rb new file mode 100644 index 000000000..ab90ca13b --- /dev/null +++ b/app/lib/command_tag/commands/variables.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module CommandTag::Commands::Variables + def handle_set_at_start(args) + return if args.blank? + + args[0] = normalize(args[0]) + + case args.count + when 1 + @vars.delete(args[0]) + when 2 + @vars[args[0]] = [args.last] + else + @vars[args[0]] = args[1..-1] + end + end + + def do_unset_at_start(args) + args.each do |arg| + @vars.delete(normalize(arg)) + end + end +end |