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.
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 |
# File 'lib/probatio.rb', line 923 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.
920 921 922 |
# File 'lib/probatio.rb', line 920 def context @context end |
#delta ⇒ Object (readonly)
Returns the value of attribute delta.
919 920 921 |
# File 'lib/probatio.rb', line 919 def delta @delta end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
920 921 922 |
# File 'lib/probatio.rb', line 920 def error @error end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
920 921 922 |
# File 'lib/probatio.rb', line 920 def group @group end |
#leaf ⇒ Object (readonly)
Returns the value of attribute leaf.
920 921 922 |
# File 'lib/probatio.rb', line 920 def leaf @leaf end |
#leave_delta ⇒ Object
Returns the value of attribute leave_delta.
921 922 923 |
# File 'lib/probatio.rb', line 921 def leave_delta @leave_delta end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
920 921 922 |
# File 'lib/probatio.rb', line 920 def name @name end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
920 921 922 |
# File 'lib/probatio.rb', line 920 def opts @opts end |
#tstamp ⇒ Object (readonly)
Returns the value of attribute tstamp.
919 920 921 |
# File 'lib/probatio.rb', line 919 def tstamp @tstamp end |
Instance Method Details
#delta_s ⇒ Object
961 962 963 964 965 |
# File 'lib/probatio.rb', line 961 def delta_s led = determine_leave_delta led ? Probatio.to_time_s(led) : '?' end |
#depth ⇒ Object
943 |
# File 'lib/probatio.rb', line 943 def depth; node.depth rescue 0; end |
#determine_leave_delta ⇒ Object
954 955 956 957 958 959 |
# File 'lib/probatio.rb', line 954 def determine_leave_delta lev = Probatio.recorder_plugin.test_leave_event(node) lev && lev.leave_delta end |
#direction ⇒ Object
941 |
# File 'lib/probatio.rb', line 941 def direction; @direction ||= name.split('_').last.to_sym; end |
#enter? ⇒ Boolean
951 |
# File 'lib/probatio.rb', line 951 def enter?; direction == :enter; end |
#leave? ⇒ Boolean
952 |
# File 'lib/probatio.rb', line 952 def leave?; direction == :leave; end |
#location ⇒ Object
967 968 969 970 971 |
# File 'lib/probatio.rb', line 967 def location (error && error.respond_to?(:location) && error.location) || (node && node.location) end |
#node ⇒ Object
942 |
# File 'lib/probatio.rb', line 942 def node; @leaf || @group; end |
#node_full_name ⇒ Object
which, in the case of assertion != self.node.type …
949 |
# File 'lib/probatio.rb', line 949 def node_full_name; node && node.full_name; end |
#path ⇒ Object
973 974 975 976 |
# File 'lib/probatio.rb', line 973 def path node && node.path end |
#to_h ⇒ Object
996 997 998 999 |
# File 'lib/probatio.rb', line 996 def to_h { n: name, p: location[0], l: location[1], t: delta_s } end |
#to_s ⇒ Object
978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 |
# File 'lib/probatio.rb', line 978 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
945 |
# File 'lib/probatio.rb', line 945 def type; @name.split('_').first; end |