Exception: SGF::ParseError
- Inherits:
-
StandardError
- Object
- StandardError
- SGF::ParseError
- Defined in:
- lib/sgf/parse_error.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
-
#initialize(input, position, description = nil) ⇒ ParseError
constructor
A new instance of ParseError.
- #to_s ⇒ Object
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
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/sgf/parse_error.rb', line 3 def description @description end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
3 4 5 |
# File 'lib/sgf/parse_error.rb', line 3 def input @input end |
#position ⇒ Object (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_s ⇒ Object
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 |