Class: Remnant::Template::Rendering
- Inherits:
-
Object
- Object
- Remnant::Template::Rendering
- Defined in:
- lib/remnant/template/rendering.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#depth ⇒ Object
Returns the value of attribute depth.
-
#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
- #exclusive_time ⇒ Object
-
#initialize(name) ⇒ Rendering
constructor
A new instance of Rendering.
- #results ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize(name) ⇒ Rendering
Returns a new instance of Rendering.
11 12 13 14 15 |
# File 'lib/remnant/template/rendering.rb', line 11 def initialize(name) @name = name @children = [] @depth = 0 end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
8 9 10 |
# File 'lib/remnant/template/rendering.rb', line 8 def children @children end |
#depth ⇒ Object
Returns the value of attribute depth.
9 10 11 |
# File 'lib/remnant/template/rendering.rb', line 9 def depth @depth end |
#end_time ⇒ Object
Returns the value of attribute end_time.
6 7 8 |
# File 'lib/remnant/template/rendering.rb', line 6 def end_time @end_time end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/remnant/template/rendering.rb', line 4 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
7 8 9 |
# File 'lib/remnant/template/rendering.rb', line 7 def parent @parent end |
#start_time ⇒ Object
Returns the value of attribute start_time.
5 6 7 |
# File 'lib/remnant/template/rendering.rb', line 5 def start_time @start_time end |
Instance Method Details
#add(rendering) ⇒ Object
17 18 19 20 21 |
# File 'lib/remnant/template/rendering.rb', line 17 def add(rendering) @children << rendering rendering.depth = depth + 1 rendering.parent = self end |
#child_time ⇒ Object
31 32 33 |
# File 'lib/remnant/template/rendering.rb', line 31 def child_time children.inject(0.0) {|memo, c| memo + c.time} end |
#exclusive_time ⇒ Object
27 28 29 |
# File 'lib/remnant/template/rendering.rb', line 27 def exclusive_time time - child_time end |
#results ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/remnant/template/rendering.rb', line 35 def results @results ||= {name.to_s => { 'time' => time * 1000, 'exclusive' => exclusive_time * 1000, 'depth' => depth, 'children' => children.map(&:results) } } end |
#time ⇒ Object
23 24 25 |
# File 'lib/remnant/template/rendering.rb', line 23 def time @end_time - @start_time end |