Method: ANTLR3::StringStream#inspect

Defined in:
lib/antlr3/streams.rb

#inspect(before_chars = 6, after_chars = 10) ⇒ Object

customized object inspection that shows:

  • the stream class

  • the stream’s location in index / line:column format

  • before_chars characters before the cursor (6 characters by default)

  • after_chars characters after the cursor (10 characters by default)



638
639
640
641
642
643
644
645
646
647
# File 'lib/antlr3/streams.rb', line 638

def inspect( before_chars = 6, after_chars = 10 )
  before = through( -before_chars ).inspect
  @position - before_chars > 0 and before.insert( 0, '... ' )
  
  after = through( after_chars ).inspect
  @position + after_chars + 1 < @data.length and after << ' ...'
  
  location = "#@position / line #@line:#@column"
  "#<#{ self.class }: #{ before } | #{ after } @ #{ location }>"
end