Class: RPStringScanner
- Defined in:
- lib/ruby_parser/ruby_parser_extras.rb
Instance Method Summary collapse
-
#current_line ⇒ Object
end.
- #extra_lines_added ⇒ Object
- #extra_lines_added=(val) ⇒ Object
- #getch ⇒ Object
- #lineno ⇒ Object
- #old_getch ⇒ Object
- #old_scan ⇒ Object
- #scan(re) ⇒ Object
-
#unread_many(str) ⇒ Object
TODO: once we get rid of these, we can make things like TODO: current_line and lineno much more accurate and easy to do.
Instance Method Details
#current_line ⇒ Object
end
33 34 35 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 33 def current_line # HAHA fuck you (HACK) string[0..pos][/\A.*__LINE__/m].split(/\n/).size end |
#extra_lines_added ⇒ Object
37 38 39 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 37 def extra_lines_added @extra_lines_added ||= 0 end |
#extra_lines_added=(val) ⇒ Object
41 42 43 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 41 def extra_lines_added= val @extra_lines_added = val end |
#getch ⇒ Object
60 61 62 63 64 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 60 def getch c = self.old_getch p :getch => [c, caller.first] c end |
#lineno ⇒ Object
45 46 47 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 45 def lineno string[0...pos].count("\n") + 1 - extra_lines_added end |
#old_getch ⇒ Object
59 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 59 alias :old_getch :getch |
#old_scan ⇒ Object
66 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 66 alias :old_scan :scan |
#scan(re) ⇒ Object
67 68 69 70 71 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 67 def scan re s = old_scan re p :scan => [s, caller.first] if s s end |
#unread_many(str) ⇒ Object
TODO: once we get rid of these, we can make things like TODO: current_line and lineno much more accurate and easy to do
52 53 54 55 56 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 52 def unread_many str # TODO: remove this entirely - we should not need it warn({:unread_many => caller[0]}.inspect) if ENV['TALLY'] self.extra_lines_added += str.count("\n") string[pos, 0] = str end |