Class: ImageToVideoAI::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/image_to_video_ai/client.rb

Constant Summary collapse

TERMINAL_STATUSES =
%w[success failed canceled].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Task

Returns a new instance of Task.



25
26
27
28
29
30
31
# File 'lib/image_to_video_ai/client.rb', line 25

def initialize(data)
  @task_id = data.fetch("taskId")
  @request_id = data["requestId"]
  @status = data.fetch("status")
  @url = data["url"]
  @videos = data["videos"] || []
end

Instance Attribute Details

#request_idObject (readonly)

Returns the value of attribute request_id.



23
24
25
# File 'lib/image_to_video_ai/client.rb', line 23

def request_id
  @request_id
end

#statusObject (readonly)

Returns the value of attribute status.



23
24
25
# File 'lib/image_to_video_ai/client.rb', line 23

def status
  @status
end

#task_idObject (readonly)

Returns the value of attribute task_id.



23
24
25
# File 'lib/image_to_video_ai/client.rb', line 23

def task_id
  @task_id
end

#urlObject (readonly)

Returns the value of attribute url.



23
24
25
# File 'lib/image_to_video_ai/client.rb', line 23

def url
  @url
end

#videosObject (readonly)

Returns the value of attribute videos.



23
24
25
# File 'lib/image_to_video_ai/client.rb', line 23

def videos
  @videos
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/image_to_video_ai/client.rb', line 33

def complete?
  TERMINAL_STATUSES.include?(status)
end

#successful?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/image_to_video_ai/client.rb', line 37

def successful?
  status == "success"
end