Class: Insight::TemplatesPanel::Rendering
- Inherits:
-
Object
- Object
- Insight::TemplatesPanel::Rendering
- Defined in:
- lib/insight/panels/templates_panel/rendering.rb
Instance Attribute Summary (collapse)
-
- (Object) children
readonly
Returns the value of attribute children.
-
- (Object) name
Returns the value of attribute name.
-
- (Object) parent
Returns the value of attribute parent.
-
- (Object) timing
Returns the value of attribute timing.
Instance Method Summary (collapse)
- - (Object) add(rendering)
- - (Object) child_duration
- - (Object) children_html
- - (Object) delete(rendering)
- - (Object) duration
- - (Object) duration_summary
- - (Object) end_time
- - (Object) exclusive_duration
- - (Object) html
-
- (Rendering) initialize(name, timing = nil)
constructor
A new instance of Rendering.
- - (Object) joined_children_html
- - (Object) start_time (also: #time)
Constructor Details
- (Rendering) initialize(name, timing = nil)
A new instance of Rendering
10 11 12 13 14 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 10 def initialize(name, timing = nil) @name = name @timing = timing @children = [] end |
Instance Attribute Details
- (Object) children (readonly)
Returns the value of attribute children
8 9 10 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 8 def children @children end |
- (Object) name
Returns the value of attribute name
5 6 7 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 5 def name @name end |
- (Object) parent
Returns the value of attribute parent
6 7 8 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 6 def parent @parent end |
- (Object) timing
Returns the value of attribute timing
7 8 9 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 7 def timing @timing end |
Instance Method Details
- (Object) add(rendering)
25 26 27 28 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 25 def add(rendering) @children << rendering rendering.parent = self end |
- (Object) child_duration
46 47 48 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 46 def child_duration children.inject(0.0) { |memo, c| memo + c.duration } end |
- (Object) children_html
67 68 69 70 71 72 73 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 67 def children_html return "" unless children.any? <<-HTML <ul>#{joined_children_html}</ul> HTML end |
- (Object) delete(rendering)
30 31 32 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 30 def delete(rendering) @children.delete(rendering) end |
- (Object) duration
34 35 36 37 38 39 40 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 34 def duration if @timing @timing.duration else child_duration end end |
- (Object) duration_summary
50 51 52 53 54 55 56 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 50 def duration_summary if children.any? "%.2fms, %.2f exclusive" % [duration, exclusive_duration] else "%.2fms" % (duration) end end |
- (Object) end_time
21 22 23 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 21 def end_time @timing.end end |
- (Object) exclusive_duration
42 43 44 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 42 def exclusive_duration duration - child_duration end |
- (Object) html
57 58 59 60 61 62 63 64 65 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 57 def html <<-HTML <li> <p>#{name} (#{duration_summary})</p> #{children_html} </li> HTML end |
- (Object) joined_children_html
75 76 77 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 75 def joined_children_html children.map { |c| c.html }.join end |
- (Object) start_time Also known as: time
16 17 18 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 16 def start_time @timing.start end |