Class: Timify::Span

Inherits:
Object
  • Object
show all
Defined in:
lib/timify/span.rb

Overview

One timed block or mark in the tree returned by #totals.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, location:, started_mark: nil) ⇒ Span

Returns a new instance of Span.



8
9
10
11
12
13
14
15
# File 'lib/timify/span.rb', line 8

def initialize(label:, location:, started_mark: nil)
  @label = label
  @location = location
  @started_mark = started_mark
  @inclusive = 0.0
  @exclusive = 0.0
  @children = []
end

Instance Attribute Details

#children ⇒ Object

Returns the value of attribute children.



6
7
8
# File 'lib/timify/span.rb', line 6

def children
  @children
end

#exclusive ⇒ Object

Returns the value of attribute exclusive.



6
7
8
# File 'lib/timify/span.rb', line 6

def exclusive
  @exclusive
end

#inclusive ⇒ Object

Returns the value of attribute inclusive.



6
7
8
# File 'lib/timify/span.rb', line 6

def inclusive
  @inclusive
end

#label ⇒ Object

Returns the value of attribute label.



6
7
8
# File 'lib/timify/span.rb', line 6

def label
  @label
end

#location ⇒ Object

Returns the value of attribute location.



6
7
8
# File 'lib/timify/span.rb', line 6

def location
  @location
end

#started_mark ⇒ Object

Returns the value of attribute started_mark.



6
7
8
# File 'lib/timify/span.rb', line 6

def started_mark
  @started_mark
end

Instance Method Details

#to_h ⇒ Hash

Returns:

  • (Hash)


18
19
20
21
22
23
24
25
26
# File 'lib/timify/span.rb', line 18

def to_h
  {
    label: label,
    location: location,
    secs: exclusive,
    inclusive: inclusive,
    children: children.map(&:to_h)
  }
end