Class: RubyProf::JsonPrinter

Inherits:
AbstractPrinter
  • Object
show all
Defined in:
lib/ruby-prof/json_printer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ JsonPrinter

Returns a new instance of JsonPrinter.



7
8
9
10
11
12
13
# File 'lib/ruby-prof/json_printer.rb', line 7

def initialize(result)
  super(result)
  @threads = {
    :overall_time => 0, # TODO
    :threads => result.threads.keys.map {|thread_id| thread_info(thread_id) }
  }
end

Instance Attribute Details

#threadsObject (readonly)

Returns the value of attribute threads.



6
7
8
# File 'lib/ruby-prof/json_printer.rb', line 6

def threads
  @threads
end

Instance Method Details



15
16
17
# File 'lib/ruby-prof/json_printer.rb', line 15

def print(output = STDOUT, options = {})
  output.puts JSON.pretty_generate(@threads)
end