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.
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
445 446 447 |
# File 'lib/rdoc/markup/parser.rb', line 445 def eos? @s.eos? end |
#matched ⇒ Object
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 |
#pos ⇒ Object
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 |