Class: Insight::TemplatesPanel::Rendering
- Inherits:
-
Object
- Object
- Insight::TemplatesPanel::Rendering
- Defined in:
- lib/insight/panels/templates_panel/rendering.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#timing ⇒ Object
Returns the value of attribute timing.
Instance Method Summary collapse
- #add(rendering) ⇒ Object
- #child_duration ⇒ Object
- #children_html ⇒ Object
- #delete(rendering) ⇒ Object
- #duration ⇒ Object
- #duration_summary ⇒ Object
- #end_time ⇒ Object
- #exclusive_duration ⇒ Object
- #html ⇒ Object
-
#initialize(name, timing = nil) ⇒ Rendering
constructor
A new instance of Rendering.
- #joined_children_html ⇒ Object
- #start_time ⇒ Object (also: #time)
Constructor Details
#initialize(name, timing = nil) ⇒ Rendering
Returns 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
#children ⇒ Object (readonly)
Returns the value of attribute children.
8 9 10 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 8 def children @children end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 5 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
6 7 8 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 6 def parent @parent end |
#timing ⇒ Object
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
#add(rendering) ⇒ Object
25 26 27 28 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 25 def add(rendering) @children << rendering rendering.parent = self end |
#child_duration ⇒ Object
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 |
#children_html ⇒ Object
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 |
#delete(rendering) ⇒ Object
30 31 32 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 30 def delete(rendering) @children.delete(rendering) end |
#duration ⇒ Object
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 |
#duration_summary ⇒ Object
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 |
#end_time ⇒ Object
21 22 23 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 21 def end_time @timing.end end |
#exclusive_duration ⇒ Object
42 43 44 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 42 def exclusive_duration duration - child_duration end |
#html ⇒ Object
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 |
#joined_children_html ⇒ Object
75 76 77 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 75 def joined_children_html children.map { |c| c.html }.join end |
#start_time ⇒ Object Also known as: time
16 17 18 |
# File 'lib/insight/panels/templates_panel/rendering.rb', line 16 def start_time @timing.start end |