Exception: Invokr::InputError
- Inherits:
-
ArgumentError
- Object
- ArgumentError
- Invokr::InputError
- Defined in:
- lib/invokr/errors.rb
Instance Attribute Summary collapse
-
#missing_args ⇒ Object
readonly
Returns the value of attribute missing_args.
Instance Method Summary collapse
- #build_message ⇒ Object
- #concat_missing_args ⇒ Object
- #display(arg) ⇒ Object
-
#initialize(missing_args) ⇒ InputError
constructor
A new instance of InputError.
- #message ⇒ Object
Constructor Details
#initialize(missing_args) ⇒ InputError
Returns a new instance of InputError.
5 6 7 8 |
# File 'lib/invokr/errors.rb', line 5 def initialize missing_args @missing_args = missing_args missing_args.map! do |arg| display arg end end |
Instance Attribute Details
#missing_args ⇒ Object (readonly)
Returns the value of attribute missing_args.
3 4 5 |
# File 'lib/invokr/errors.rb', line 3 def missing_args @missing_args end |
Instance Method Details
#build_message ⇒ Object
14 15 16 17 18 |
# File 'lib/invokr/errors.rb', line 14 def prefix = "cannot invoke; missing required arguments: " prefix << concat_missing_args prefix end |
#concat_missing_args ⇒ Object
20 21 22 23 24 |
# File 'lib/invokr/errors.rb', line 20 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 |
#display(arg) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/invokr/errors.rb', line 26 def display arg list = Array(arg).map do |arg| "`#{arg}'" end str = list * " or " str.insert 0, "either " if list.size > 1 str end |
#message ⇒ Object
10 11 12 |
# File 'lib/invokr/errors.rb', line 10 def @message ||= end |