# class RubyProf::AbstractPrinter

### Public Class Methods

needs_dir?() click to toggle source

whether this printer need a :path option pointing to a directory

    # File lib/ruby-prof/printers/abstract_printer.rb, line 98
    def self.needs_dir?
      false
    end

new(result) click to toggle source

Create a new printer.

result should be the output generated from a profiling run

    # File lib/ruby-prof/printers/abstract_printer.rb, line 7
    def initialize(result)
      @result = result
      @output = nil
    end

### Public Instance Methods

editor_uri() click to toggle source

    # File lib/ruby-prof/printers/abstract_printer.rb, line 47
    def editor_uri
      default_uri = if RUBY_PLATFORM =~ /darwin/                      && !ENV['RUBY_PROF_EDITOR_URI']
                      'txmt'
                    else
                      false
                    end
      ENV['RUBY_PROF_EDITOR_URI'] || @options[:editor_uri] || default_uri
    end

method_name(method) click to toggle source

    # File lib/ruby-prof/printers/abstract_printer.rb, line 57
    def method_name(method)
      name = method.full_name
      if print_file
        name += " (#{method.source_file}:#{method.line}}"
      end
      name
    end

min_percent() click to toggle source

    # File lib/ruby-prof/printers/abstract_printer.rb, line 35
    def min_percent
      @options[:min_percent] || 0
    end

print(output = STDOUT, options = {}) click to toggle source

Print a profiling report to the provided output.

output - Any IO object, including STDOUT or a file. The default value is STDOUT.

options - Hash of print options. See setup_options for more information. Note that each printer can define its own set of options.

    # File lib/ruby-prof/printers/abstract_printer.rb, line 73
    def print(output = STDOUT, options = {})
      @output = output
      setup_options(options)
      print_threads
    end

print_file() click to toggle source

    # File lib/ruby-prof/printers/abstract_printer.rb, line 39
    def print_file
      @options[:print_file] || false
    end

print_header(thread) click to toggle source

    # File lib/ruby-prof/printers/abstract_printer.rb, line 91
    def print_header(thread)
    end

print_thread(thread) click to toggle source

    # File lib/ruby-prof/printers/abstract_printer.rb, line 85
    def print_thread(thread)
      print_header(thread)
      print_methods(thread)
      print_footer(thread)
    end

print_threads() click to toggle source

    # File lib/ruby-prof/printers/abstract_printer.rb, line 79
    def print_threads
      @result.threads.each do |thread|
        print_thread(thread)
      end
    end

setup_options(options = {}) click to toggle source

Specify print options.

options - Hash table

    :min_percent - Number 0 to 100 that specifes the minimum
                   %self (the methods self time divided by the
                   overall total time) that a method must take
                   for it to be printed out in the report.
                   Default value is 0.

    :print_file  - True or false. Specifies if a method's source
                   file should be printed.  Default value if false.

    :sort_method - Specifies method used for sorting method infos.
                   Available values are :total_time, :self_time,
                   :wait_time, :children_time
                   Default value is :total_time
     :editor_uri - Specifies editor uri scheme used for opening files
                   e.g. :atm or :mvim. For OS X default is :txmt.
                   Use RUBY_PROF_EDITOR_URI environment variable to overide.

    # File lib/ruby-prof/printers/abstract_printer.rb, line 31
    def setup_options(options = {})
      @options = options
    end

sort_method() click to toggle source

    # File lib/ruby-prof/printers/abstract_printer.rb, line 43
    def sort_method
      @options[:sort_method] || :total_time
    end