Class: Ecoportal::API::V1::Job::Status
- Inherits:
-
Object
- Object
- Ecoportal::API::V1::Job::Status
- Defined in:
- lib/ecoportal/api/v1/job/status.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
Instance Method Summary collapse
- #complete?(total = nil) ⇒ Boolean
- #errored? ⇒ Boolean
-
#initialize(id, complete, errored, progress) ⇒ Status
constructor
A new instance of Status.
- #pending(total) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id, complete, errored, progress) ⇒ Status
Returns a new instance of Status.
8 9 10 11 12 13 |
# File 'lib/ecoportal/api/v1/job/status.rb', line 8 def initialize(id, complete, errored, progress) @id = id @complete = complete @errored = errored @progress = progress end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/ecoportal/api/v1/job/status.rb', line 6 def id @id end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
6 7 8 |
# File 'lib/ecoportal/api/v1/job/status.rb', line 6 def progress @progress end |
Instance Method Details
#complete?(total = nil) ⇒ Boolean
15 16 17 18 19 |
# File 'lib/ecoportal/api/v1/job/status.rb', line 15 def complete?(total = nil) return @complete if total.nil? progress >= total end |
#errored? ⇒ Boolean
28 29 30 |
# File 'lib/ecoportal/api/v1/job/status.rb', line 28 def errored? @errored end |
#pending(total) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ecoportal/api/v1/job/status.rb', line 21 def pending(total) return 1 unless total return 0 if total <= progress total - progress end |
#to_s ⇒ Object
32 33 34 35 36 37 |
# File 'lib/ecoportal/api/v1/job/status.rb', line 32 def to_s msg = complete? ? "Completed" : "In progress" msg = "Errored" if errored? msg << " with #{progress} done." msg end |