Class: Wherewolf::ParseError

Inherits:
Parslet::ParseFailed
  • Object
show all
Defined in:
lib/wherewolf/parse_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ ParseError

Returns a new instance of ParseError.



4
5
6
# File 'lib/wherewolf/parse_error.rb', line 4

def initialize(parent)
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/wherewolf/parse_error.rb', line 3

def parent
  @parent
end

Instance Method Details

#error_messageObject



12
13
14
# File 'lib/wherewolf/parse_error.rb', line 12

def error_message
  "Parsing error occured at character #{position}"
end

#positionObject



8
9
10
# File 'lib/wherewolf/parse_error.rb', line 8

def position
  parent.cause.source.pos
end

#to_sObject



16
17
18
# File 'lib/wherewolf/parse_error.rb', line 16

def to_s
  error_message
end