Class: Bitmovin::Encoding::Inputs::AnalysisTask
- Inherits:
-
Object
- Object
- Bitmovin::Encoding::Inputs::AnalysisTask
- Defined in:
- lib/bitmovin/encoding/inputs/analysis_task.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#input_id ⇒ Object
readonly
Returns the value of attribute input_id.
Instance Method Summary collapse
- #created? ⇒ Boolean
- #error? ⇒ Boolean
- #eta? ⇒ Boolean
- #finished? ⇒ Boolean
-
#initialize(input, analysis_id) ⇒ AnalysisTask
constructor
- Creates a new Analysis object == Parameters: input
- Either an input-id (string) or a InputResource analysis_id
-
Id of the analysis task.
- #input ⇒ Object
- #progress? ⇒ Boolean
- #queued? ⇒ Boolean
-
#result ⇒ Object
Returns the analysis result Will raise and error if analysis is not yet finished.
- #running? ⇒ Boolean
- #status ⇒ Object
Constructor Details
#initialize(input, analysis_id) ⇒ AnalysisTask
Creates a new Analysis object
Parameters:
- input
-
Either an input-id (string) or a InputResource
- analysis_id
-
Id of the analysis task
9 10 11 12 13 14 15 16 17 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 9 def initialize(input, analysis_id) if (input.instance_of?(String)) @input_id = input else @input_id = input.id @input = input end @id = analysis_id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
19 20 21 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 19 def id @id end |
#input_id ⇒ Object (readonly)
Returns the value of attribute input_id.
19 20 21 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 19 def input_id @input_id end |
Instance Method Details
#created? ⇒ Boolean
36 37 38 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 36 def created? status.status == "CREATED" end |
#error? ⇒ Boolean
52 53 54 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 52 def error? status.status == "ERROR" end |
#eta? ⇒ Boolean
56 57 58 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 56 def eta? status.eta end |
#finished? ⇒ Boolean
48 49 50 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 48 def finished? status.status == "FINISHED" end |
#input ⇒ Object
21 22 23 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 21 def input @input end |
#progress? ⇒ Boolean
60 61 62 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 60 def progress? status.progress end |
#queued? ⇒ Boolean
40 41 42 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 40 def queued? status.status == "QUEUED" end |
#result ⇒ Object
Returns the analysis result Will raise and error if analysis is not yet finished
66 67 68 69 70 71 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 66 def result if !finished? raise BitmovinError.new(self), "analysis is not finished yet" end Analysis.new(@input_id).find(@id) end |
#running? ⇒ Boolean
44 45 46 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 44 def running? status.status == "RUNNING" end |
#status ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bitmovin/encoding/inputs/analysis_task.rb', line 25 def status five_seconds_ago = (Time.now - 5) puts @last_status_call if @last_status_call.nil? || @last_status_call <= five_seconds_ago response = Bitmovin.client.get File.join("/v1/encoding/inputs/", @input_id, "analysis", @id, "status") @status_result = OpenStruct.new(JSON.parse(response.body)['data']['result']['analysis']) @last_status_call = Time.now end @status_result end |