Class: Ecoportal::API::V1::JobStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/ecoportal/api/v1/job_status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, complete, errored, progress) ⇒ JobStatus

Returns a new instance of JobStatus.

[View source]

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

#idObject (readonly)

Returns the value of attribute id.


5
6
7
# File 'lib/ecoportal/api/v1/job_status.rb', line 5

def id
  @id
end

#progressObject (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

Returns:

  • (Boolean)
[View source]

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

Returns:

  • (Boolean)
[View source]

20
21
22
# File 'lib/ecoportal/api/v1/job_status.rb', line 20

def errored?
  @errored
end

#to_sObject

[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