lib/invokr/errors.rb in invokr-0.9.5 vs lib/invokr/errors.rb in invokr-0.9.6

- old
+ new

@@ -2,11 +2,11 @@ class InputError < ArgumentError attr :missing_args def initialize missing_args @missing_args = missing_args - missing_args.map! do |arg| "`#{arg}'" end + missing_args.map! do |arg| display arg end end def message @message ||= build_message end @@ -19,9 +19,16 @@ def concat_missing_args return missing_args.first if missing_args.size == 1 last_arg = missing_args.pop "#{missing_args.join ', '} and #{last_arg}" + end + + def display arg + list = Array(arg).map do |arg| "`#{arg}'" end + str = list * " or " + str.insert 0, "either " if list.size > 1 + str end end class BadArgumentsError < ArgumentError attr :builder, :args