Class: Orchestra::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/orchestra/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent = nil, payload = nil) ⇒ Event

Returns a new instance of Event.



5
6
7
8
9
10
11
# File 'lib/orchestra/event.rb', line 5

def initialize(name, parent=nil, payload=nil)
  @name      = name
  @time      = Time.now.utc
  @thread_id = Thread.current.object_id
  @parent    = parent
  @payload   = payload || []
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



3
4
5
# File 'lib/orchestra/event.rb', line 3

def duration
  @duration
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/orchestra/event.rb', line 3

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/orchestra/event.rb', line 3

def parent
  @parent
end

#payloadObject (readonly)

Returns the value of attribute payload.



3
4
5
# File 'lib/orchestra/event.rb', line 3

def payload
  @payload
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



3
4
5
# File 'lib/orchestra/event.rb', line 3

def thread_id
  @thread_id
end

#timeObject (readonly)

Returns the value of attribute time.



3
4
5
# File 'lib/orchestra/event.rb', line 3

def time
  @time
end

Instance Method Details

#finish!Object



13
14
15
# File 'lib/orchestra/event.rb', line 13

def finish!
  @duration = Time.now.utc - @time
end

#finished?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/orchestra/event.rb', line 17

def finished?
  !!@duration
end

#parent?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/orchestra/event.rb', line 21

def parent?
  !!@parent
end

#payload?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/orchestra/event.rb', line 25

def payload?
  !@payload.empty?
end