Class: Rack::Bug::TemplatesPanel::Rendering
- Inherits:
-
Object
- Object
- Rack::Bug::TemplatesPanel::Rendering
- Defined in:
- lib/rack/bug/panels/templates_panel/rendering.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Instance Method Summary collapse
- #add(rendering) ⇒ Object
- #child_time ⇒ Object
- #children_html ⇒ Object
- #exclusive_time ⇒ Object
- #html ⇒ Object
-
#initialize(name) ⇒ Rendering
constructor
A new instance of Rendering.
- #joined_children_html ⇒ Object
- #time ⇒ Object
- #time_summary ⇒ Object
Constructor Details
#initialize(name) ⇒ Rendering
Returns a new instance of Rendering.
13 14 15 16 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 13 def initialize(name) @name = name @children = [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
10 11 12 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 10 def children @children end |
#end_time ⇒ Object
Returns the value of attribute end_time.
8 9 10 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 8 def end_time @end_time end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 6 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
9 10 11 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 9 def parent @parent end |
#start_time ⇒ Object
Returns the value of attribute start_time.
7 8 9 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 7 def start_time @start_time end |
Instance Method Details
#add(rendering) ⇒ Object
18 19 20 21 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 18 def add(rendering) @children << rendering rendering.parent = self end |
#child_time ⇒ Object
31 32 33 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 31 def child_time children.inject(0.0) { |memo, c| memo + c.time } end |
#children_html ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 52 def children_html return "" unless children.any? <<-HTML <ul>#{joined_children_html}</ul> HTML end |
#exclusive_time ⇒ Object
27 28 29 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 27 def exclusive_time time - child_time end |
#html ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 42 def html <<-HTML <li> <p>#{name} (#{time_summary})</p> #{children_html} </li> HTML end |
#joined_children_html ⇒ Object
60 61 62 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 60 def joined_children_html children.map { |c| c.html }.join end |
#time ⇒ Object
23 24 25 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 23 def time @end_time - @start_time end |
#time_summary ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/rack/bug/panels/templates_panel/rendering.rb', line 35 def time_summary if children.any? "%.2fms, %.2f exclusive" % [time * 1_000, exclusive_time * 1_000] else "%.2fms" % (time * 1_000) end end |