Hook this when adding custom formatters. Check out lib/awesome_print/ext directory for custom formatters that ship with awesome_print.
# File lib/awesome_print/formatter.rb, line 36 def cast(object, type) CORE.grep(type)[0] || :self end
Pick the color and apply it to the given string as necessary.
# File lib/awesome_print/formatter.rb, line 42 def colorize(str, type) str = CGI.escapeHTML(str) if @options[:html] if @options[:plain] || !@options[:color][type] || !@inspector.colorize? str # # Check if the string color method is defined by awesome_print and accepts # html parameter or it has been overriden by some gem such as colorize. # elsif str.method(@options[:color][type]).arity == -1 # Accepts html parameter. str.send(@options[:color][type], @options[:html]) else str = %<kbd style="color:#{@options[:color][type]}">#{str}</kbd>| if @options[:html] str.send(@options[:color][type]) end end
Main entry point to format an object.
# File lib/awesome_print/formatter.rb, line 23 def format(object, type = nil) core_class = cast(object, type) awesome = if core_class != :self send(:"awesome_#{core_class}", object) # Core formatters. else awesome_self(object, type) # Catch all that falls back to object.inspect. end @options[:html] ? "<pre>#{awesome}</pre>" : awesome end
Generated with the Darkfish Rdoc Generator 2.