Class: TTY::Option::MissingParameter

Inherits:
ParseError show all
Defined in:
lib/tty/option/errors.rb

Overview

Raised when a parameter is required but not present

Constant Summary collapse

MESSAGE =
"%<type>s '%<name>s' must be provided"

Instance Attribute Summary

Attributes inherited from ParseError

#param

Instance Method Summary collapse

Constructor Details

#initialize(param_or_message) ⇒ MissingParameter

Returns a new instance of MissingParameter.


111
112
113
114
115
116
117
118
119
120
# File 'lib/tty/option/errors.rb', line 111

def initialize(param_or_message)
  if param_or_message.is_a?(Parameter)
    @param = param_or_message
    message = format(MESSAGE, name: param.name, type: param.to_sym)
  else
    message = param_or_message
  end

  super(message)
end