Class: AsposeWordsCloud::JobHandler
- Inherits:
-
Object
- Object
- AsposeWordsCloud::JobHandler
- Defined in:
- lib/aspose_words_cloud/job_handler.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(api, request, info) ⇒ JobHandler
constructor
A new instance of JobHandler.
- #message ⇒ Object
- #status ⇒ Object
- #update ⇒ Object
- #wait_result(update_interval = 3) ⇒ Object
Constructor Details
#initialize(api, request, info) ⇒ JobHandler
Returns a new instance of JobHandler.
30 31 32 33 34 35 |
# File 'lib/aspose_words_cloud/job_handler.rb', line 30 def initialize(api, request, info) @api = api @request = request @info = info @result = nil end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
28 29 30 |
# File 'lib/aspose_words_cloud/job_handler.rb', line 28 def result @result end |
Instance Method Details
#message ⇒ Object
41 42 43 |
# File 'lib/aspose_words_cloud/job_handler.rb', line 41 def @info. || '' end |
#status ⇒ Object
37 38 39 |
# File 'lib/aspose_words_cloud/job_handler.rb', line 37 def status @info.status || '' end |
#update ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/aspose_words_cloud/job_handler.rb', line 45 def update raise ApiError.new(code: 400, message: 'Invalid job id.', response_headers: {}, response_body: '') if @info.job_id.nil? parts = @api.call_job_result(@info.job_id) if parts.length >= 1 @info = @api.api_client.deserialize_job_info_part(parts[0]) if parts.length >= 2 && succeeded? @result = @api.api_client.deserialize_http_response_part(@request, parts[1][:data]) end end @result end |
#wait_result(update_interval = 3) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/aspose_words_cloud/job_handler.rb', line 59 def wait_result(update_interval = 3) while queued? || processing? sleep(update_interval) update end update if succeeded? && @result.nil? unless succeeded? raise ApiError.new( code: 400, message: "Job failed with status \"#{status}\" - \"#{}\".", response_headers: {}, response_body: '' ) end @result end |