Class: Low::Events::EventTree

Inherits:
Object
  • Object
show all
Defined in:
lib/pool/event_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventTree

Returns a new instance of EventTree.



9
10
11
12
13
14
# File 'lib/pool/event_tree.rb', line 9

def initialize
  @root_event = nil
  @current_event = nil

  @sequence = []
end

Instance Attribute Details

#current_eventObject

Returns the value of attribute current_event.



7
8
9
# File 'lib/pool/event_tree.rb', line 7

def current_event
  @current_event
end

#root_eventObject (readonly)

Returns the value of attribute root_event.



6
7
8
# File 'lib/pool/event_tree.rb', line 6

def root_event
  @root_event
end

#sequenceObject (readonly)

Returns the value of attribute sequence.



6
7
8
# File 'lib/pool/event_tree.rb', line 6

def sequence
  @sequence
end

Instance Method Details

#branch(event:) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/pool/event_tree.rb', line 16

def branch(event:)
  @sequence << event

  if @root_event.nil?
    @root_event = event
    @current_event = event
  else
    @current_event.children << event
  end
end