Class: RubyProf::FlameGraphJsonPrinter::FlameDataJsonPrinter
- Inherits:
-
Object
- Object
- RubyProf::FlameGraphJsonPrinter::FlameDataJsonPrinter
- Defined in:
- lib/ruby-prof/printers/flame_graph_json_printer.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #enter(name, called, self_value, total_value) ⇒ Object
-
#initialize(output, options = {}) ⇒ FlameDataJsonPrinter
constructor
A new instance of FlameDataJsonPrinter.
- #leave ⇒ Object
Constructor Details
#initialize(output, options = {}) ⇒ FlameDataJsonPrinter
Returns a new instance of FlameDataJsonPrinter.
74 75 76 77 78 79 80 81 |
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 74 def initialize(output, ={}) @output = output @depth = [:depth] || 0 @anchored = .fetch(:anchored, false) @pretty = .fetch(:pretty, false) @state = :root update_layout end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
72 73 74 |
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 72 def output @output end |
Instance Method Details
#enter(name, called, self_value, total_value) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 83 def enter(name, called, self_value, total_value) case @state when :enter put_line "," put_part "\"children\": [" step_in(:enter) when :leave put_part ", " end put_line "{" step_in(:enter) put_line "\"name\": \"#{name}\"," put_line "\"called\": #{called}," put_line "\"lost\": #{self_value}," put_part "\"value\": #{total_value}" end |
#leave ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ruby-prof/printers/flame_graph_json_printer.rb', line 101 def leave case @state when :enter new_line when :leave step_out(:leave) put_line "]" end step_out(:leave) put_part "}" end |