Class: WhirledPeas::Graphics::Debugger

Inherits:
Object
  • Object
show all
Defined in:
lib/whirled_peas/graphics/debugger.rb

Instance Method Summary collapse

Constructor Details

#initialize(painter) ⇒ Debugger

Returns a new instance of Debugger.



9
10
11
# File 'lib/whirled_peas/graphics/debugger.rb', line 9

def initialize(painter)
  @painter = painter
end

Instance Method Details

#debug(indent = '') ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/whirled_peas/graphics/debugger.rb', line 13

def debug(indent='')
  info = [
    "#{indent}* #{painter.class}(#{painter.name})",
  ]
  info << "#{indent + '  '}- Dimensions(#{dimensions})"
  info << "#{indent + '  '}- Theme=#{painter.settings.theme.inspect}" if indent == ''
  info << "#{indent + '  '}- Settings"
  info << Settings::Debugger.new(painter.settings).debug(indent + '    ')
  if painter.is_a?(TextPainter)
    content = painter.content
    info << "#{indent + '  '}- Content(value=#{content})"
  elsif painter.is_a?(ContainerPainter)
    info << "#{indent + '  '}- Children"
    info += painter.each_child.map { |c| Debugger.new(c).debug(indent + '    ') }
  end
  info.join("\n")
end