Class: Minstrel::Event
- Inherits:
-
Object
- Object
- Minstrel::Event
- Defined in:
- lib/minstrel.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#args_hash ⇒ Object
Returns the value of attribute args_hash.
-
#args_order ⇒ Object
Returns the value of attribute args_order.
-
#binding ⇒ Object
Returns the value of attribute binding.
-
#class ⇒ Object
Returns the value of attribute class.
-
#depth ⇒ Object
The call stack depth of this event.
-
#duration ⇒ Object
Duration is only valid for ‘return’ or ‘c-return’ events.
-
#file ⇒ Object
Returns the value of attribute file.
-
#line ⇒ Object
Returns the value of attribute line.
-
#method ⇒ Object
Returns the value of attribute method.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #args ⇒ Object
- #block_given? ⇒ Boolean
- #entry? ⇒ Boolean
- #exit? ⇒ Boolean
-
#initialize(action, file, line, method, binding, klass) ⇒ Event
constructor
A new instance of Event.
- #symbol ⇒ Object
- #to_s ⇒ Object
- #use_related_event(event) ⇒ Object
Constructor Details
#initialize(action, file, line, method, binding, klass) ⇒ Event
Returns a new instance of Event.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/minstrel.rb', line 33 def initialize(action, file, line, method, binding, klass) @action = action @file = file @line = line @method = method @binding = binding @class = klass @timestamp = Time.now if ["c-call", "call"].include?(@action) @args_hash = {} @args_order = eval('local_variables', binding) # In ruby 1.9, local_variables returns an array of symbols, not strings. @args_order.collect { |v| @args_hash[v] = eval(v.to_s, binding) } end @block_given = eval('block_given?', @binding) end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
16 17 18 |
# File 'lib/minstrel.rb', line 16 def action @action end |
#args_hash ⇒ Object
Returns the value of attribute args_hash.
22 23 24 |
# File 'lib/minstrel.rb', line 22 def args_hash @args_hash end |
#args_order ⇒ Object
Returns the value of attribute args_order.
23 24 25 |
# File 'lib/minstrel.rb', line 23 def args_order @args_order end |
#binding ⇒ Object
Returns the value of attribute binding.
20 21 22 |
# File 'lib/minstrel.rb', line 20 def binding @binding end |
#class ⇒ Object
Returns the value of attribute class.
21 22 23 |
# File 'lib/minstrel.rb', line 21 def class @class end |
#depth ⇒ Object
The call stack depth of this event
30 31 32 |
# File 'lib/minstrel.rb', line 30 def depth @depth end |
#duration ⇒ Object
Duration is only valid for ‘return’ or ‘c-return’ events
27 28 29 |
# File 'lib/minstrel.rb', line 27 def duration @duration end |
#file ⇒ Object
Returns the value of attribute file.
17 18 19 |
# File 'lib/minstrel.rb', line 17 def file @file end |
#line ⇒ Object
Returns the value of attribute line.
18 19 20 |
# File 'lib/minstrel.rb', line 18 def line @line end |
#method ⇒ Object
Returns the value of attribute method.
19 20 21 |
# File 'lib/minstrel.rb', line 19 def method @method end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
24 25 26 |
# File 'lib/minstrel.rb', line 24 def @timestamp end |
Instance Method Details
#args ⇒ Object
55 56 57 58 |
# File 'lib/minstrel.rb', line 55 def args return nil unless @args_order return @args_order.collect { |v| @args_hash[v] } end |
#block_given? ⇒ Boolean
82 83 84 |
# File 'lib/minstrel.rb', line 82 def block_given? @block_given end |
#entry? ⇒ Boolean
70 71 72 |
# File 'lib/minstrel.rb', line 70 def entry? return ["c-call", "call"].include?(action) end |
#exit? ⇒ Boolean
76 77 78 |
# File 'lib/minstrel.rb', line 76 def exit? return ["c-return", "return"].include?(action) end |
#symbol ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/minstrel.rb', line 87 def symbol case @action when "c-call", "call" ; return "=>" when "c-return", "return" ; return "<=" when "raise"; return "<E" else return " +" end end |
#to_s ⇒ Object
97 98 99 |
# File 'lib/minstrel.rb', line 97 def to_s return "#{" " * @depth}#{symbol} #{@class.to_s}##{@method}(#{args.inspect}) #{block_given? ? "{ ... }" : ""} (thread=#{Thread.current}) #{@duration.nil? ? "" : sprintf("(%.5f seconds)", @duration)}" end |
#use_related_event(event) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/minstrel.rb', line 61 def (event) @args_order = event.args_order @args_hash = event.args_hash @block_given = event.block_given? @duration = @timestamp - event. end |