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
A new instance of MyStringScanner.
- #matched ⇒ Object
- #newline! ⇒ Object
- #pos ⇒ Object
- #scan(re) ⇒ Object
- #unscan(s) ⇒ Object
Constructor Details
#initialize(input) ⇒ MyStringScanner
Returns a new instance of MyStringScanner.
423 424 425 426 |
# File 'lib/rdoc/markup/parser.rb', line 423 def initialize(input) @line = @column = 0 @s = StringScanner.new input end |
Instance Method Details
#[](i) ⇒ Object
456 457 458 |
# File 'lib/rdoc/markup/parser.rb', line 456 def [](i) @s[i] end |
#eos? ⇒ Boolean
448 449 450 |
# File 'lib/rdoc/markup/parser.rb', line 448 def eos? @s.eos? end |
#matched ⇒ Object
452 453 454 |
# File 'lib/rdoc/markup/parser.rb', line 452 def matched @s.matched end |
#newline! ⇒ Object
443 444 445 446 |
# File 'lib/rdoc/markup/parser.rb', line 443 def newline! @column = 0 @line += 1 end |
#pos ⇒ Object
439 440 441 |
# File 'lib/rdoc/markup/parser.rb', line 439 def pos [@column, @line] end |
#scan(re) ⇒ Object
428 429 430 431 432 |
# File 'lib/rdoc/markup/parser.rb', line 428 def scan(re) ret = @s.scan(re) @column += ret.length if ret ret end |
#unscan(s) ⇒ Object
434 435 436 437 |
# File 'lib/rdoc/markup/parser.rb', line 434 def unscan(s) @s.pos -= s.bytesize @column -= s.length end |