Class: Probatio::Event
- Inherits:
-
Object
- Object
- Probatio::Event
- Defined in:
- lib/probatio.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#delta ⇒ Object
readonly
Returns the value of attribute delta.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#leaf ⇒ Object
readonly
Returns the value of attribute leaf.
-
#leave_delta ⇒ Object
Returns the value of attribute leave_delta.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#tstamp ⇒ Object
readonly
Returns the value of attribute tstamp.
Instance Method Summary collapse
- #delta_s ⇒ Object
- #depth ⇒ Object
- #determine_leave_delta ⇒ Object
- #direction ⇒ Object
- #enter? ⇒ Boolean
-
#initialize(name, details) ⇒ Event
constructor
A new instance of Event.
- #leave? ⇒ Boolean
- #location ⇒ Object
- #node ⇒ Object
-
#node_full_name ⇒ Object
which, in the case of assertion != self.node.type ...
- #path ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(name, details) ⇒ Event
Returns a new instance of Event.
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 |
# File 'lib/probatio.rb', line 804 def initialize(name, details) @tstamp, @delta = Probatio.monow_and_delta @name = name.to_s details.each do |d| case d when Hash then @opts = d when Exception then @error = d when Probatio::Leaf then @leaf = d when Probatio::Group then @group = d when Probatio::Context then @context = d else fail ArgumentError.new("cannot fathom #{d.class} #{d.inspect}") end end end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
801 802 803 |
# File 'lib/probatio.rb', line 801 def context @context end |
#delta ⇒ Object (readonly)
Returns the value of attribute delta.
800 801 802 |
# File 'lib/probatio.rb', line 800 def delta @delta end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
801 802 803 |
# File 'lib/probatio.rb', line 801 def error @error end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
801 802 803 |
# File 'lib/probatio.rb', line 801 def group @group end |
#leaf ⇒ Object (readonly)
Returns the value of attribute leaf.
801 802 803 |
# File 'lib/probatio.rb', line 801 def leaf @leaf end |
#leave_delta ⇒ Object
Returns the value of attribute leave_delta.
802 803 804 |
# File 'lib/probatio.rb', line 802 def leave_delta @leave_delta end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
801 802 803 |
# File 'lib/probatio.rb', line 801 def name @name end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
801 802 803 |
# File 'lib/probatio.rb', line 801 def opts @opts end |
#tstamp ⇒ Object (readonly)
Returns the value of attribute tstamp.
800 801 802 |
# File 'lib/probatio.rb', line 800 def tstamp @tstamp end |
Instance Method Details
#delta_s ⇒ Object
842 843 844 845 846 |
# File 'lib/probatio.rb', line 842 def delta_s led = determine_leave_delta led ? Probatio.to_time_s(led) : '?' end |
#depth ⇒ Object
824 |
# File 'lib/probatio.rb', line 824 def depth; node.depth rescue 0; end |
#determine_leave_delta ⇒ Object
835 836 837 838 839 840 |
# File 'lib/probatio.rb', line 835 def determine_leave_delta lev = Probatio.recorder_plugin.test_leave_event(node) lev && lev.leave_delta end |
#direction ⇒ Object
822 |
# File 'lib/probatio.rb', line 822 def direction; @direction ||= name.split('_').last.to_sym; end |
#enter? ⇒ Boolean
832 |
# File 'lib/probatio.rb', line 832 def enter?; direction == :enter; end |
#leave? ⇒ Boolean
833 |
# File 'lib/probatio.rb', line 833 def leave?; direction == :leave; end |
#location ⇒ Object
848 849 850 851 852 |
# File 'lib/probatio.rb', line 848 def location (error && error.respond_to?(:location) && error.location) || (node && node.location) end |
#node ⇒ Object
823 |
# File 'lib/probatio.rb', line 823 def node; @leaf || @group; end |
#node_full_name ⇒ Object
which, in the case of assertion != self.node.type ...
830 |
# File 'lib/probatio.rb', line 830 def node_full_name; node && node.full_name; end |
#path ⇒ Object
854 855 856 857 |
# File 'lib/probatio.rb', line 854 def path node && node.path end |
#to_h ⇒ Object
877 878 879 880 |
# File 'lib/probatio.rb', line 877 def to_h { n: name, p: location[0], l: location[1], t: delta_s } end |
#to_s ⇒ Object
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 |
# File 'lib/probatio.rb', line 859 def to_s led = determine_leave_delta o = StringIO.new o << "<event" o << "\n name=#{name.inspect}" o << "\n node=#{node.full_name.inspect}" if node o << "\n node_type=#{node.type.inspect}" if node o << "\n error=#{error.to_s.inspect}" if error o << "\n location=#{location.map(&:to_s).join(':').inspect}" if node o << "\n delta=\"#{Probatio.to_time_s(delta)}\"" if delta o << "\n leave_delta=\"#{Probatio.to_time_s(led)}\"" if led o << " />" o.string end |
#type ⇒ Object
826 |
# File 'lib/probatio.rb', line 826 def type; @name.split('_').first; end |