Class: Noteikumi::Result
- Inherits:
-
Object
- Object
- Noteikumi::Result
- Defined in:
- lib/noteikumi/result.rb
Overview
Represents the result of running a specific rule
Instance Attribute Summary collapse
-
#end_time ⇒ Time?
readonly
The time the rule ended.
-
#exception ⇒ Exception?
The exception a rule raised.
-
#output ⇒ Object?
Any output returned from the rule run block.
-
#rule ⇒ Rule?
readonly
The rule the result relates to.
-
#run_time ⇒ Float
readonly
The time it took for the rule to be processed.
-
#start_time ⇒ Time?
readonly
The time the rule started.
Instance Method Summary collapse
-
#error? ⇒ Boolean
If the result has an exception.
-
#initialize(rule) ⇒ Result
constructor
Creates a result for a rule.
-
#inspect ⇒ String
:nodoc:.
-
#name ⇒ String, Symbol
The rule name.
-
#ran? ⇒ Boolean
Determines if this rule ran.
-
#start_processing ⇒ Time
Records the start time for the rule process.
-
#stop_processing ⇒ Time
Records that processing have ended.
Constructor Details
#initialize(rule) ⇒ Result
Creates a result for a rule
35 36 37 38 39 40 41 42 43 |
# File 'lib/noteikumi/result.rb', line 35 def initialize(rule) @rule = rule @start_time = nil @end_time = nil @run_time = nil @exception = nil @output = nil @ran = false end |
Instance Attribute Details
#end_time ⇒ Time? (readonly)
The time the rule ended
14 15 16 |
# File 'lib/noteikumi/result.rb', line 14 def end_time @end_time end |
#exception ⇒ Exception?
The exception a rule raised
25 26 27 |
# File 'lib/noteikumi/result.rb', line 25 def exception @exception end |
#output ⇒ Object?
Any output returned from the rule run block
17 18 19 |
# File 'lib/noteikumi/result.rb', line 17 def output @output end |
#rule ⇒ Rule? (readonly)
The rule the result relates to
21 22 23 |
# File 'lib/noteikumi/result.rb', line 21 def rule @rule end |
#run_time ⇒ Float (readonly)
The time it took for the rule to be processed
6 7 8 |
# File 'lib/noteikumi/result.rb', line 6 def run_time @run_time end |
#start_time ⇒ Time? (readonly)
The time the rule started
10 11 12 |
# File 'lib/noteikumi/result.rb', line 10 def start_time @start_time end |
Instance Method Details
#error? ⇒ Boolean
If the result has an exception
55 56 57 |
# File 'lib/noteikumi/result.rb', line 55 def error? !!exception end |
#inspect ⇒ String
:nodoc:
84 85 86 |
# File 'lib/noteikumi/result.rb', line 84 def inspect "#<%s:%s rule: %s ran: %s error: %s>" % [self.class, object_id, name, ran?, error?] end |
#name ⇒ String, Symbol
The rule name
48 49 50 |
# File 'lib/noteikumi/result.rb', line 48 def name @rule.name end |
#ran? ⇒ Boolean
Determines if this rule ran
62 63 64 |
# File 'lib/noteikumi/result.rb', line 62 def ran? @ran end |
#start_processing ⇒ Time
Records the start time for the rule process
69 70 71 72 |
# File 'lib/noteikumi/result.rb', line 69 def start_processing @ran = true @start_time = Time.now end |
#stop_processing ⇒ Time
Records that processing have ended
77 78 79 80 |
# File 'lib/noteikumi/result.rb', line 77 def stop_processing @end_time = Time.now @run_time = @end_time - @start_time end |