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

Returns a new instance of MyStringScanner.



420
421
422
423
# File 'lib/rdoc/markup/parser.rb', line 420

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

Instance Method Details

#[](i) ⇒ Object



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

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

#eos?Boolean

Returns:

  • (Boolean)


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

def eos?
  @s.eos?
end

#matchedObject



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

def matched
  @s.matched
end

#newline!Object



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

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

#posObject



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

def pos
  [@column, @line]
end

#scan(re) ⇒ Object



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

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

#unscan(s) ⇒ Object



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

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