Class: RPStringScanner

Inherits:
StringScanner
  • Object
show all
Defined in:
lib/rp_stringscanner.rb

Instance Method Summary collapse

Instance Method Details

#d(o) ⇒ Object



29
30
31
# File 'lib/rp_stringscanner.rb', line 29

def d o
  STDERR.puts o.inspect
end

#getchObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rp_stringscanner.rb', line 5

def getch
  c = super
  where = caller.drop_while { |s| s =~ /(getch|nextc).$/ }.first
  where = where.split(/:/).first(2).join(":")
  if ENV["TALLY"] then
    d getch:where
  else
    d getch:[c, where]
  end
  c
end

#scan(re) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rp_stringscanner.rb', line 17

def scan re
  s = super
  where = caller.drop_while { |x| x =~ /scan.$/ }.first
  where = where.split(/:/).first(2).join(":")
  if ENV["TALLY"] then
    d scan:[where]
  else
    d scan:[s, where] if s
  end
  s
end