Class: RDoc::Markup::Parser::MyStringScanner
- Inherits:
-
Object
- Object
- RDoc::Markup::Parser::MyStringScanner
- 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
- #[](i) ⇒ Object
- #eos? ⇒ Boolean
-
#initialize(input) ⇒ MyStringScanner
constructor
:stopdoc:.
- #matched ⇒ Object
- #newline! ⇒ Object
- #pos ⇒ Object
- #scan(re) ⇒ Object
- #unscan(s) ⇒ Object
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
450 451 452 |
# File 'lib/rdoc/markup/parser.rb', line 450 def eos? @s.eos? end |
#matched ⇒ Object
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 |
#pos ⇒ Object
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 |