Class: Pask::Event
- Inherits:
-
Object
- Object
- Pask::Event
- Defined in:
- lib/pask/event.rb
Constant Summary collapse
- CALL =
"call"- C_CALL =
"c-call"- RETURN =
"return"- C_RETURN =
"c-return"- KNOWN_NAMES =
[CALL, C_CALL, RETURN, C_RETURN].map!(&:freeze)
Instance Method Summary collapse
- #-(other) ⇒ Object
- #__binding__ ⇒ Object
- #any_call? ⇒ Boolean
- #any_return? ⇒ Boolean
- #binding ⇒ Object
- #c_call? ⇒ Boolean
- #c_return? ⇒ Boolean
- #call? ⇒ Boolean
- #created_at ⇒ Object
- #emit_by ⇒ Object
- #emit_by_method ⇒ Object
- #file ⇒ Object
-
#initialize(name, other) ⇒ Event
constructor
A new instance of Event.
- #lineno ⇒ Object
- #origin?(mod) ⇒ Boolean
- #return? ⇒ Boolean
- #signature ⇒ Object
- #to_f ⇒ Object
Constructor Details
#initialize(name, other) ⇒ Event
Returns a new instance of Event.
8 9 10 11 12 13 14 15 |
# File 'lib/pask/event.rb', line 8 def initialize(name, other) @name = name @other = other @created_at = Time.now @signature = nil @to_f = nil @emit_by = binding.eval "self" end |
Instance Method Details
#-(other) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/pask/event.rb', line 90 def -(other) unless other.respond_to?(:to_f) raise TypeError, "cannot coerce argument to a float" end to_f - other.to_f end |
#__binding__ ⇒ Object
46 47 48 |
# File 'lib/pask/event.rb', line 46 def __binding__ Kernel.binding end |
#any_call? ⇒ Boolean
50 51 52 |
# File 'lib/pask/event.rb', line 50 def any_call? call? or c_call? end |
#any_return? ⇒ Boolean
70 71 72 |
# File 'lib/pask/event.rb', line 70 def any_return? return? or c_return? end |
#binding ⇒ Object
42 43 44 |
# File 'lib/pask/event.rb', line 42 def binding @other[:binding] end |
#c_call? ⇒ Boolean
66 67 68 |
# File 'lib/pask/event.rb', line 66 def c_call? @name == C_CALL end |
#c_return? ⇒ Boolean
58 59 60 |
# File 'lib/pask/event.rb', line 58 def c_return? @name == C_RETURN end |
#call? ⇒ Boolean
62 63 64 |
# File 'lib/pask/event.rb', line 62 def call? @name == CALL end |
#created_at ⇒ Object
26 27 28 |
# File 'lib/pask/event.rb', line 26 def created_at @created_at end |
#emit_by ⇒ Object
17 18 19 20 |
# File 'lib/pask/event.rb', line 17 def emit_by # FIXME: messed up for C calls and returns. maybe return nil for them? @emit_by end |
#emit_by_method ⇒ Object
38 39 40 |
# File 'lib/pask/event.rb', line 38 def emit_by_method @other[:method] end |
#file ⇒ Object
30 31 32 |
# File 'lib/pask/event.rb', line 30 def file @other[:file] end |
#lineno ⇒ Object
34 35 36 |
# File 'lib/pask/event.rb', line 34 def lineno @other[:lineno] end |
#origin?(mod) ⇒ Boolean
74 75 76 77 78 79 80 |
# File 'lib/pask/event.rb', line 74 def origin?(mod) if emit_by.respond_to?(:ancestors) emit_by.ancestors.include?(mod) else mod === emit_by end end |
#return? ⇒ Boolean
54 55 56 |
# File 'lib/pask/event.rb', line 54 def return? @name == RETURN end |
#signature ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/pask/event.rb', line 82 def signature @signature ||= if emit_by.kind_of?(Module) [emit_by, @method].join(".") else [emit_by.class, @method].join("#") end end |
#to_f ⇒ Object
22 23 24 |
# File 'lib/pask/event.rb', line 22 def to_f @to_f ||= @created_at.to_f end |