Class: Ecoportal::API::V1::JobStatus
- Inherits:
-
Object
- Object
- Ecoportal::API::V1::JobStatus
- 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) ⇒ JobStatus
constructor
A new instance of JobStatus.
- #to_s ⇒ Object
Constructor Details
#initialize(id, complete, errored, progress) ⇒ JobStatus
Returns a new instance of JobStatus.
7 8 9 10 11 12 |
# File 'lib/ecoportal/api/v1/job_status.rb', line 7 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.
5 6 7 |
# File 'lib/ecoportal/api/v1/job_status.rb', line 5 def id @id end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
5 6 7 |
# File 'lib/ecoportal/api/v1/job_status.rb', line 5 def progress @progress end |
Instance Method Details
#complete?(total = nil) ⇒ Boolean
14 15 16 17 18 |
# File 'lib/ecoportal/api/v1/job_status.rb', line 14 def complete?(total = nil) return @complete if total.nil? progress >= total end |
#errored? ⇒ Boolean
20 21 22 |
# File 'lib/ecoportal/api/v1/job_status.rb', line 20 def errored? @errored end |
#to_s ⇒ Object
[View source]
24 25 26 27 28 29 |
# File 'lib/ecoportal/api/v1/job_status.rb', line 24 def to_s msg = complete? ? "Completed" : "In progress" msg = "Errored" if errored? msg << " with #{progress} done." msg end |