Class: Mindee::V1::Parsing::Common::Job
- Inherits:
-
Object
- Object
- Mindee::V1::Parsing::Common::Job
- Defined in:
- lib/mindee/v1/parsing/common/job.rb
Overview
Job (queue) information on async parsing.
Instance Attribute Summary collapse
- #available_at ⇒ Time? readonly
- #error ⇒ Hash? readonly
-
#id ⇒ String
readonly
Mindee ID of the document.
- #issued_at ⇒ Time readonly
- #millisecs_taken ⇒ Integer? readonly
- #status ⇒ JobStatus, Symbol readonly
Instance Method Summary collapse
-
#initialize(http_response) ⇒ Job
constructor
A new instance of Job.
Constructor Details
#initialize(http_response) ⇒ Job
Returns a new instance of Job.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mindee/v1/parsing/common/job.rb', line 25 def initialize(http_response) @id = http_response['id'] @error = http_response['error'] @issued_at = Time.iso8601(http_response['issued_at']) if http_response.key?('available_at') && !http_response['available_at'].nil? @available_at = Time.iso8601(http_response['available_at']) @millisecs_taken = (1000 * (@available_at.to_time - @issued_at.to_time).to_f).to_i end @status = case http_response['status'] when 'waiting' JobStatus::WAITING when 'processing' JobStatus::PROCESSING when 'completed' JobStatus::COMPLETED else http_response['status']&.to_sym end end |
Instance Attribute Details
#available_at ⇒ Time? (readonly)
16 17 18 |
# File 'lib/mindee/v1/parsing/common/job.rb', line 16 def available_at @available_at end |
#error ⇒ Hash? (readonly)
22 23 24 |
# File 'lib/mindee/v1/parsing/common/job.rb', line 22 def error @error end |
#id ⇒ String (readonly)
Returns Mindee ID of the document.
12 13 14 |
# File 'lib/mindee/v1/parsing/common/job.rb', line 12 def id @id end |
#issued_at ⇒ Time (readonly)
14 15 16 |
# File 'lib/mindee/v1/parsing/common/job.rb', line 14 def issued_at @issued_at end |
#millisecs_taken ⇒ Integer? (readonly)
20 21 22 |
# File 'lib/mindee/v1/parsing/common/job.rb', line 20 def millisecs_taken @millisecs_taken end |
#status ⇒ JobStatus, Symbol (readonly)
18 19 20 |
# File 'lib/mindee/v1/parsing/common/job.rb', line 18 def status @status end |