Class: Workerholic::JobStatistics
- Inherits:
-
Object
- Object
- Workerholic::JobStatistics
- Defined in:
- lib/workerholic/job_statistics.rb
Instance Attribute Summary collapse
-
#completed_at ⇒ Object
Returns the value of attribute completed_at.
-
#enqueued_at ⇒ Object
Returns the value of attribute enqueued_at.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#failed_on ⇒ Object
Returns the value of attribute failed_on.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
Instance Method Summary collapse
- #elapsed_time ⇒ Object
- #format_elapsed_time(time) ⇒ Object
-
#initialize(options = {}) ⇒ JobStatistics
constructor
A new instance of JobStatistics.
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ JobStatistics
Returns a new instance of JobStatistics.
10 11 12 13 14 15 |
# File 'lib/workerholic/job_statistics.rb', line 10 def initialize(={}) @enqueued_at = [:enqueued_at] @errors = [:errors] || [] @started_at = [:started_at] @completed_at = [:completed_at] end |
Instance Attribute Details
#completed_at ⇒ Object
Returns the value of attribute completed_at.
4 5 6 |
# File 'lib/workerholic/job_statistics.rb', line 4 def completed_at @completed_at end |
#enqueued_at ⇒ Object
Returns the value of attribute enqueued_at.
4 5 6 |
# File 'lib/workerholic/job_statistics.rb', line 4 def enqueued_at @enqueued_at end |
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/workerholic/job_statistics.rb', line 4 def errors @errors end |
#failed_on ⇒ Object
Returns the value of attribute failed_on.
4 5 6 |
# File 'lib/workerholic/job_statistics.rb', line 4 def failed_on @failed_on end |
#started_at ⇒ Object
Returns the value of attribute started_at.
4 5 6 |
# File 'lib/workerholic/job_statistics.rb', line 4 def started_at @started_at end |
Instance Method Details
#elapsed_time ⇒ Object
28 29 30 31 32 |
# File 'lib/workerholic/job_statistics.rb', line 28 def elapsed_time if completed_at && started_at format_elapsed_time(completed_at - started_at) end end |
#format_elapsed_time(time) ⇒ Object
34 35 36 |
# File 'lib/workerholic/job_statistics.rb', line 34 def format_elapsed_time(time) '%.10f' % time end |
#to_hash ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/workerholic/job_statistics.rb', line 17 def to_hash { enqueued_at: enqueued_at, errors: errors, started_at: started_at, completed_at: completed_at, elapsed_time: elapsed_time, failed_on: failed_on } end |