Class: Remnant::Template::Rendering

Inherits:
Object
  • Object
show all
Defined in:
lib/remnant/template/rendering.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#childrenObject

Returns the value of attribute children.



8
9
10
# File 'lib/remnant/template/rendering.rb', line 8

def children
  @children
end

#depthObject

Returns the value of attribute depth.



9
10
11
# File 'lib/remnant/template/rendering.rb', line 9

def depth
  @depth
end

#end_timeObject

Returns the value of attribute end_time.



6
7
8
# File 'lib/remnant/template/rendering.rb', line 6

def end_time
  @end_time
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/remnant/template/rendering.rb', line 4

def name
  @name
end

#parentObject

Returns the value of attribute parent.



7
8
9
# File 'lib/remnant/template/rendering.rb', line 7

def parent
  @parent
end

#start_timeObject

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_timeObject



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_timeObject



27
28
29
# File 'lib/remnant/template/rendering.rb', line 27

def exclusive_time
  time - child_time
end

#resultsObject



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

#timeObject



23
24
25
# File 'lib/remnant/template/rendering.rb', line 23

def time
  @end_time - @start_time
end