Class: Derketo::EventTrace

Inherits:
Object
  • Object
show all
Defined in:
lib/derketo/event_trace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventTrace

Returns a new instance of EventTrace.



4
5
6
7
8
# File 'lib/derketo/event_trace.rb', line 4

def initialize
  @first = nil
  @last = nil
  @length = 0
end

Instance Attribute Details

#firstObject

Returns the value of attribute first.



3
4
5
# File 'lib/derketo/event_trace.rb', line 3

def first
  @first
end

#lastObject

Returns the value of attribute last.



3
4
5
# File 'lib/derketo/event_trace.rb', line 3

def last
  @last
end

#lengthObject

Returns the value of attribute length.



3
4
5
# File 'lib/derketo/event_trace.rb', line 3

def length
  @length
end

Instance Method Details

#allObject



21
22
23
24
25
26
27
28
29
# File 'lib/derketo/event_trace.rb', line 21

def all
  @_events = []
  event = @first
  while event.nil? == false
    @_events << event
    event = event.next
  end
  @_events
end

#empty?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/derketo/event_trace.rb', line 31

def empty?
  @length == 0
end

#push(event) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/derketo/event_trace.rb', line 10

def push(event)
  if @first.nil?
    @first = event
  else
    event.previous = @last
    @last.next = event
  end
  @last = event
  @length += 1
end