Class: Mindee::Parsing::Common::Job
- Inherits:
-
Object
- Object
- Mindee::Parsing::Common::Job
- Defined in:
- lib/mindee/parsing/common/api_response.rb
Overview
Job (queue) information on async parsing.
Instance Attribute Summary collapse
- #available_at ⇒ Mindee::Parsing::Standard::DateField? readonly
- #error ⇒ Hash? readonly
-
#id ⇒ String
readonly
Mindee ID of the document.
- #issued_at ⇒ Mindee::Parsing::Standard::DateField 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.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mindee/parsing/common/api_response.rb', line 45 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 ⇒ Mindee::Parsing::Standard::DateField? (readonly)
36 37 38 |
# File 'lib/mindee/parsing/common/api_response.rb', line 36 def available_at @available_at end |
#error ⇒ Hash? (readonly)
42 43 44 |
# File 'lib/mindee/parsing/common/api_response.rb', line 42 def error @error end |
#id ⇒ String (readonly)
Returns Mindee ID of the document.
32 33 34 |
# File 'lib/mindee/parsing/common/api_response.rb', line 32 def id @id end |
#issued_at ⇒ Mindee::Parsing::Standard::DateField (readonly)
34 35 36 |
# File 'lib/mindee/parsing/common/api_response.rb', line 34 def issued_at @issued_at end |
#millisecs_taken ⇒ Integer? (readonly)
40 41 42 |
# File 'lib/mindee/parsing/common/api_response.rb', line 40 def millisecs_taken @millisecs_taken end |
#status ⇒ JobStatus, Symbol (readonly)
38 39 40 |
# File 'lib/mindee/parsing/common/api_response.rb', line 38 def status @status end |