Exception: Samovar::InvalidInputError

Inherits:
Error
  • Object
show all
Defined in:
lib/samovar/error.rb

Overview

Raised when invalid input is provided on the command line.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, input) ⇒ InvalidInputError

Initialize a new invalid input error.



17
18
19
20
21
22
# File 'lib/samovar/error.rb', line 17

def initialize(command, input)
  @command = command
  @input = input
  
  super "Could not parse token #{input.first.inspect}"
end

Instance Attribute Details

#commandObject

The command that encountered the error.



41
42
43
# File 'lib/samovar/error.rb', line 41

def command
  @command
end

#inputObject (readonly)

The remaining input that could not be parsed.



46
47
48
# File 'lib/samovar/error.rb', line 46

def input
  @input
end

Instance Method Details

#help?Boolean

Check if the error was caused by a help request.

Returns:

  • (Boolean)


34
35
36
# File 'lib/samovar/error.rb', line 34

def help?
  self.token == "--help"
end

#tokenObject

The token that could not be parsed.



27
28
29
# File 'lib/samovar/error.rb', line 27

def token
  @input.first
end