Exception: Yay::UnexpectedTokenError

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

Instance Attribute Summary collapse

Attributes inherited from Error

#position

Instance Method Summary collapse

Methods inherited from Error

#printable_position

Constructor Details

#initialize(type, value, position) ⇒ UnexpectedTokenError

Returns a new instance of UnexpectedTokenError.



108
109
110
111
112
# File 'lib/yay/errors.rb', line 108

def initialize type, value, position
  @type     = type
  @value    = value
  @position = position
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



105
106
107
# File 'lib/yay/errors.rb', line 105

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



106
107
108
# File 'lib/yay/errors.rb', line 106

def value
  @value
end

Instance Method Details

#extra_messageObject



114
115
116
117
# File 'lib/yay/errors.rb', line 114

def extra_message
  return "Since #{value} has a special meaning, try enclosing it in quotes or a regex when searching for it" if type == "colour"
  return ""
end

#printable_messageObject



119
120
121
# File 'lib/yay/errors.rb', line 119

def printable_message
  return "Unexpected #{type} \"#{value}\"#{printable_position}\n#{extra_message}"
end