Class: Pakyow::Data::UnknownCommand

Inherits:
Error
  • Object
show all
Defined in:
lib/pakyow/data/errors.rb

Instance Method Summary collapse

Instance Method Details

#contextual_messageObject



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/pakyow/data/errors.rb', line 104

def contextual_message
  if commands.any?
    String.new(
      <<~MESSAGE
        The following commands are defined for #{@context.__object_name.name}:
      MESSAGE
    ).tap do |message|
      commands.keys.each do |command|
        message << "  * #{command}\n"
      end
    end
  else
    String.new(
      <<~MESSAGE
        No commands are defined for #{@context.__object_name.name}.
      MESSAGE
    )
  end
end