Class: Mindee::Parsing::Common::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/parsing/common/job.rb

Overview

Job (queue) information on async parsing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ Job

Returns a new instance of Job.

Parameters:

  • http_response (Hash)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mindee/parsing/common/job.rb', line 24

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_atTime? (readonly)

Returns:

  • (Time, nil)


15
16
17
# File 'lib/mindee/parsing/common/job.rb', line 15

def available_at
  @available_at
end

#errorHash? (readonly)

Returns:

  • (Hash, nil)


21
22
23
# File 'lib/mindee/parsing/common/job.rb', line 21

def error
  @error
end

#idString (readonly)

Returns Mindee ID of the document.

Returns:

  • (String)

    Mindee ID of the document



11
12
13
# File 'lib/mindee/parsing/common/job.rb', line 11

def id
  @id
end

#issued_atTime (readonly)

Returns:

  • (Time)


13
14
15
# File 'lib/mindee/parsing/common/job.rb', line 13

def issued_at
  @issued_at
end

#millisecs_takenInteger? (readonly)

Returns:

  • (Integer, nil)


19
20
21
# File 'lib/mindee/parsing/common/job.rb', line 19

def millisecs_taken
  @millisecs_taken
end

#statusJobStatus, Symbol (readonly)

Returns:



17
18
19
# File 'lib/mindee/parsing/common/job.rb', line 17

def status
  @status
end