Class: ActiveJob::Status::Progress
- Inherits:
-
Object
- Object
- ActiveJob::Status::Progress
- Defined in:
- lib/activejob-status/progress.rb
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#progress ⇒ Object
Returns the value of attribute progress.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
- #decrement(num = 1) ⇒ Object
- #finish ⇒ Object
- #increment(num = 1) ⇒ Object
-
#initialize(job) ⇒ Progress
constructor
A new instance of Progress.
- #to_h ⇒ Object
Constructor Details
#initialize(job) ⇒ Progress
Returns a new instance of Progress.
11 12 13 14 15 |
# File 'lib/activejob-status/progress.rb', line 11 def initialize(job) @job = job @total = 100 @progress = 0 end |
Instance Attribute Details
#job ⇒ Object (readonly)
Returns the value of attribute job.
6 7 8 |
# File 'lib/activejob-status/progress.rb', line 6 def job @job end |
#progress ⇒ Object
Returns the value of attribute progress.
6 7 8 |
# File 'lib/activejob-status/progress.rb', line 6 def progress @progress end |
#total ⇒ Object
Returns the value of attribute total.
6 7 8 |
# File 'lib/activejob-status/progress.rb', line 6 def total @total end |
Instance Method Details
#decrement(num = 1) ⇒ Object
33 34 35 36 37 |
# File 'lib/activejob-status/progress.rb', line 33 def decrement(num = 1) @progress -= num job_status.update(to_h) self end |
#finish ⇒ Object
39 40 41 42 43 |
# File 'lib/activejob-status/progress.rb', line 39 def finish @progress = @total job_status.update(to_h, force: true) self end |
#increment(num = 1) ⇒ Object
27 28 29 30 31 |
# File 'lib/activejob-status/progress.rb', line 27 def increment(num = 1) @progress += num job_status.update(to_h) self end |
#to_h ⇒ Object
45 46 47 |
# File 'lib/activejob-status/progress.rb', line 45 def to_h {progress: @progress, total: @total} end |