Class: RDoc::Markup::Parser::MyStringScanner

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/markup/parser.rb

Overview

A simple wrapper of StringScanner that is aware of the current column and lineno

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ MyStringScanner

:stopdoc:



427
428
429
430
# File 'lib/rdoc/markup/parser.rb', line 427

def initialize(input)
  @line = @column = 0
  @s = StringScanner.new input
end

Instance Method Details

#[](i) ⇒ Object



460
461
462
# File 'lib/rdoc/markup/parser.rb', line 460

def [](i)
  @s[i]
end

#eos? ⇒ Boolean

Returns:

  • (Boolean)


452
453
454
# File 'lib/rdoc/markup/parser.rb', line 452

def eos?
  @s.eos?
end

#matched ⇒ Object



456
457
458
# File 'lib/rdoc/markup/parser.rb', line 456

def matched
  @s.matched
end

#newline! ⇒ Object



447
448
449
450
# File 'lib/rdoc/markup/parser.rb', line 447

def newline!
  @column = 0
  @line += 1
end

#pos ⇒ Object



443
444
445
# File 'lib/rdoc/markup/parser.rb', line 443

def pos
  [@column, @line]
end

#scan(re) ⇒ Object



432
433
434
435
436
# File 'lib/rdoc/markup/parser.rb', line 432

def scan(re)
  ret = @s.scan(re)
  @column += ret.length if ret
  ret
end

#unscan(s) ⇒ Object



438
439
440
441
# File 'lib/rdoc/markup/parser.rb', line 438

def unscan(s)
  @s.pos -= s.bytesize
  @column -= s.length
end