Sha256: 77d5156d78986238948643f9a8a9c91f841e6c94501add223c8081d71e43e952
Contents?: true
Size: 1.59 KB
Versions: 7
Compression:
Stored size: 1.59 KB
Contents
require 'whirled_peas/settings/debugger' require_relative 'container_painter' require_relative 'text_painter' module WhirledPeas module Graphics class Debugger def initialize(painter) @painter = painter end def debug(indent='') info = [ "#{indent}* #{painter.class}(#{painter.name})", ] info << "#{indent + ' '}- Dimensions(#{dimensions})" info << "#{indent + ' '}- Settings" info << Settings::Debugger.new(painter.settings).debug(indent + ' ') if painter.is_a?(TextPainter) content = if painter.content.length > 1 '<multiline>' elsif painter.content.first.length > 12 "#{painter.content.first[0..9]}...".inspect else painter.content.first.inspect end 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 private attr_reader :painter def dimensions outer = "#{painter.dimensions.outer_width}x#{painter.dimensions.outer_height}" if painter.is_a?(ContainerPainter) content = "#{painter.dimensions.content_width}x#{painter.dimensions.content_height}" grid = "#{painter.dimensions.num_cols}x#{painter.dimensions.num_rows}" "outer=#{outer}, content=#{content}, grid=#{grid}" else "outer=#{outer}" end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems