Class: Event
- Inherits:
-
Object
- Object
- Event
- Defined in:
- lib/event.rb
Overview
An Event instance tracks the title of the task, and the required indentation to display the task in the log. This is required to store an Array of events that took place–but below the verbosity threshhold–to replay them into the log at the appropriate indention level should an exception be thrown.
Instance Attribute Summary collapse
-
#failure ⇒ Object
readonly
Publically read-only attributes.
-
#hier ⇒ Object
readonly
shows nested levels.
-
#proc ⇒ Object
readonly
Proc to call before a retry.
-
#title ⇒ Object
readonly
event title.
-
#tries ⇒ Object
readonly
number of tries remaining.
Instance Method Summary collapse
-
#child ⇒ Object
Get an Event which is the child of this event.
-
#child! ⇒ Object
Make this event into its child.
-
#sibling ⇒ Object
Get copy of Event hier to the next task at the same level of the call-stack.
-
#sibling! ⇒ Object
Take this Event hier to the next task at the same level of the call-stack.
-
#to_s ⇒ Object
Return String ready for log.
Instance Attribute Details
#failure ⇒ Object (readonly)
Publically read-only attributes
28 29 30 |
# File 'lib/event.rb', line 28 def failure @failure end |
#hier ⇒ Object (readonly)
shows nested levels
29 30 31 |
# File 'lib/event.rb', line 29 def hier @hier end |
#proc ⇒ Object (readonly)
Proc to call before a retry
30 31 32 |
# File 'lib/event.rb', line 30 def proc @proc end |
#title ⇒ Object (readonly)
event title
32 33 34 |
# File 'lib/event.rb', line 32 def title @title end |
#tries ⇒ Object (readonly)
number of tries remaining
31 32 33 |
# File 'lib/event.rb', line 31 def tries @tries end |
Instance Method Details
#child ⇒ Object
Get an Event which is the child of this event
35 36 37 |
# File 'lib/event.rb', line 35 def child self.dup.child! end |
#child! ⇒ Object
Make this event into its child
40 41 42 43 44 45 46 47 |
# File 'lib/event.rb', line 40 def child! if @hier.count('.') % 2 == 0 # if even number of periods @hier << '.a' else @hier << '.0' end self end |
#sibling ⇒ Object
Get copy of Event hier to the next task at the same level of the call-stack
50 51 52 |
# File 'lib/event.rb', line 50 def sibling self.dup.sibling! end |
#sibling! ⇒ Object
Take this Event hier to the next task at the same level of the call-stack
55 56 57 58 59 |
# File 'lib/event.rb', line 55 def sibling! # Now change the last hier to its successor @hier.sub!(/[^.]+$/) { $&.succ } self end |
#to_s ⇒ Object
Return String ready for log
62 63 64 |
# File 'lib/event.rb', line 62 def to_s @time + ': ' + @hier + ' ### ' + @title end |