Class: Derketo::EventTrace
- Inherits:
-
Object
- Object
- Derketo::EventTrace
- Defined in:
- lib/derketo/event_trace.rb
Instance Attribute Summary collapse
-
#first ⇒ Object
Returns the value of attribute first.
-
#last ⇒ Object
Returns the value of attribute last.
-
#length ⇒ Object
Returns the value of attribute length.
Instance Method Summary collapse
- #all ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ EventTrace
constructor
A new instance of EventTrace.
- #push(event) ⇒ Object
Constructor Details
#initialize ⇒ EventTrace
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
#first ⇒ Object
Returns the value of attribute first.
3 4 5 |
# File 'lib/derketo/event_trace.rb', line 3 def first @first end |
#last ⇒ Object
Returns the value of attribute last.
3 4 5 |
# File 'lib/derketo/event_trace.rb', line 3 def last @last end |
#length ⇒ Object
Returns the value of attribute length.
3 4 5 |
# File 'lib/derketo/event_trace.rb', line 3 def length @length end |
Instance Method Details
#all ⇒ Object
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
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 |