Class: Derketo::Event
- Inherits:
-
Object
- Object
- Derketo::Event
- Includes:
- Helpers
- Defined in:
- lib/derketo/events/event.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#method_id ⇒ Object
Returns the value of attribute method_id.
-
#next ⇒ Object
Returns the value of attribute next.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#previous ⇒ Object
Returns the value of attribute previous.
-
#return_value ⇒ Object
Returns the value of attribute return_value.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(tracepoint) ⇒ Event
constructor
A new instance of Event.
- #to_h ⇒ Object
-
#to_json ⇒ Object
{ "class": "Mermaid", "type": "call", "method": "initialize", "parameters": [], "return_value": null }.
-
#to_s ⇒ Object
{ :class=>"Mermaid", :type=>:call, :method=>:initialize, :parameters=>[], :return_value=>nil }.
Methods included from Helpers
Constructor Details
#initialize(tracepoint) ⇒ Event
Returns a new instance of Event.
8 9 10 11 12 13 14 15 |
# File 'lib/derketo/events/event.rb', line 8 def initialize(tracepoint) @class_name = clean(tracepoint.defined_class.to_s) @return_value = tracepoint.event == :return ? clean(tracepoint.return_value.to_s) : nil @type = tracepoint.event @method_id = clean(tracepoint.method_id.to_s) @parameters = tracepoint.self.method(tracepoint.method_id).parameters @previous = self end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
6 7 8 |
# File 'lib/derketo/events/event.rb', line 6 def class_name @class_name end |
#method_id ⇒ Object
Returns the value of attribute method_id.
6 7 8 |
# File 'lib/derketo/events/event.rb', line 6 def method_id @method_id end |
#next ⇒ Object
Returns the value of attribute next.
6 7 8 |
# File 'lib/derketo/events/event.rb', line 6 def next @next end |
#parameters ⇒ Object
Returns the value of attribute parameters.
6 7 8 |
# File 'lib/derketo/events/event.rb', line 6 def parameters @parameters end |
#previous ⇒ Object
Returns the value of attribute previous.
6 7 8 |
# File 'lib/derketo/events/event.rb', line 6 def previous @previous end |
#return_value ⇒ Object
Returns the value of attribute return_value.
6 7 8 |
# File 'lib/derketo/events/event.rb', line 6 def return_value @return_value end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/derketo/events/event.rb', line 6 def type @type end |
Instance Method Details
#to_h ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/derketo/events/event.rb', line 17 def to_h { class: @class_name, type: @type, method: @method_id, parameters: @parameters, return_value: @return_value } end |
#to_json ⇒ Object
{ "class": "Mermaid", "type": "call", "method": "initialize", "parameters": [], "return_value": null }
34 35 36 |
# File 'lib/derketo/events/event.rb', line 34 def to_json JSON.generate(to_h) end |
#to_s ⇒ Object
{ :class=>"Mermaid", :type=>:call, :method=>:initialize, :parameters=>[], :return_value=>nil }
45 46 47 |
# File 'lib/derketo/events/event.rb', line 45 def to_s to_h.to_s end |