Class: StringScanner
- Inherits:
-
Object
- Object
- StringScanner
- Defined in:
- lib/ruby_parser_extras.rb
Instance Method Summary collapse
-
#current_line ⇒ Object
end.
- #lineno ⇒ Object
- #unread(c) ⇒ Object
- #unread_many(str) ⇒ Object
- #was_begin_of_line ⇒ Object
Instance Method Details
#current_line ⇒ Object
end
30 31 32 |
# File 'lib/ruby_parser_extras.rb', line 30 def current_line # HAHA fuck you (HACK) string[0..pos][/\A.*__LINE__/m].split(/\n/).size end |
#lineno ⇒ Object
34 35 36 |
# File 'lib/ruby_parser_extras.rb', line 34 def lineno string[0..pos].split(/\n/).size end |
#unread(c) ⇒ Object
38 39 40 41 42 |
# File 'lib/ruby_parser_extras.rb', line 38 def unread c return if c.nil? # UGH warn({:unread => caller[0]}.inspect) if ENV['TALLY'] string[pos, 0] = c end |
#unread_many(str) ⇒ Object
44 45 46 47 |
# File 'lib/ruby_parser_extras.rb', line 44 def unread_many str warn({:unread_many => caller[0]}.inspect) if ENV['TALLY'] string[pos, 0] = str end |
#was_begin_of_line ⇒ Object
49 50 51 |
# File 'lib/ruby_parser_extras.rb', line 49 def was_begin_of_line pos <= 2 or string[pos-2] == ?\n end |