Class: Textpow::DebugProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/textpow/debug_processor.rb

Instance Method Summary collapse

Constructor Details

#initializeDebugProcessor

Returns a new instance of DebugProcessor.



3
4
5
6
# File 'lib/textpow/debug_processor.rb', line 3

def initialize
  @line_number = 0
  @printable_line = ""
end

Instance Method Details

#close_tag(name, position) ⇒ Object



18
19
20
# File 'lib/textpow/debug_processor.rb', line 18

def close_tag name, position
  STDERR.puts pprint( "", "}#{name}", position + @line_marks.size)
end

#end_parsing(name) ⇒ Object



32
33
34
# File 'lib/textpow/debug_processor.rb', line 32

def end_parsing name
  STDERR.puts "}#{name}"
end

#new_line(line) ⇒ Object



22
23
24
25
26
# File 'lib/textpow/debug_processor.rb', line 22

def new_line line
  @line_number += 1
  @line_marks = "[#{@line_number.to_s.rjust( 4, '0' )}] "
  STDERR.puts "#{@line_marks}#{line}"
end

#open_tag(name, position) ⇒ Object



14
15
16
# File 'lib/textpow/debug_processor.rb', line 14

def open_tag name, position
  STDERR.puts pprint( "", "{#{name}", position + @line_marks.size)
end

#pprint(line, string, position = 0) ⇒ Object



8
9
10
11
12
# File 'lib/textpow/debug_processor.rb', line 8

def pprint line, string, position = 0
  line.replace line.ljust( position + string.size, " ")
  line[position,string.size] = string
  line
end

#start_parsing(name) ⇒ Object



28
29
30
# File 'lib/textpow/debug_processor.rb', line 28

def start_parsing name
  STDERR.puts "{#{name}"
end