Exception: SGF::ParseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/sgf/parse_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, position, description = nil) ⇒ ParseError

Returns a new instance of ParseError.



5
6
7
8
9
# File 'lib/sgf/parse_error.rb', line 5

def initialize input, position, description = nil
  @input = input
  @position = position
  @description = description || "SGF parse error occurred here "
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#inputObject (readonly)

Returns the value of attribute input.



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

def input
  @input
end

#positionObject (readonly)

Returns the value of attribute position.



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

def position
  @position
end

Instance Method Details

#to_sObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sgf/parse_error.rb', line 11

def to_s
  if @position > 1000
    start_position = @position - 1000
    s = '...'
  else
    start_position = 0
    s = ''
  end
  s << @input[start_position..@position]
  s << ' <=== '
  s << description.to_s
end