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:



425
426
427
428
# File 'lib/rdoc/markup/parser.rb', line 425

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

Instance Method Details

#[](i) ⇒ Object



458
459
460
# File 'lib/rdoc/markup/parser.rb', line 458

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

#eos?Boolean

Returns:

  • (Boolean)


450
451
452
# File 'lib/rdoc/markup/parser.rb', line 450

def eos?
  @s.eos?
end

#matchedObject



454
455
456
# File 'lib/rdoc/markup/parser.rb', line 454

def matched
  @s.matched
end

#newline!Object



445
446
447
448
# File 'lib/rdoc/markup/parser.rb', line 445

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

#posObject



441
442
443
# File 'lib/rdoc/markup/parser.rb', line 441

def pos
  [@column, @line]
end

#scan(re) ⇒ Object



430
431
432
433
434
# File 'lib/rdoc/markup/parser.rb', line 430

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

#unscan(s) ⇒ Object



436
437
438
439
# File 'lib/rdoc/markup/parser.rb', line 436

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