Module: Transloadit::Response::Assembly

Defined in:
lib/transloadit/response/assembly.rb

Constant Summary collapse

DEFAULT_RELOAD_TRIES =
600

Instance Method Summary collapse

Instance Method Details

#aborted?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/transloadit/response/assembly.rb', line 12

def aborted?
  self["ok"] == "REQUEST_ABORTED"
end

#cancel!Object



8
9
10
# File 'lib/transloadit/response/assembly.rb', line 8

def cancel!
  replace Transloadit::Request.new(self["assembly_ssl_url"]).delete
end

#canceled?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/transloadit/response/assembly.rb', line 16

def canceled?
  self["ok"] == "ASSEMBLY_CANCELED"
end

#completed?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/transloadit/response/assembly.rb', line 20

def completed?
  self["ok"] == "ASSEMBLY_COMPLETED"
end

#error?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/transloadit/response/assembly.rb', line 24

def error?
  self["error"] != nil
end

#executing?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/transloadit/response/assembly.rb', line 28

def executing?
  self["ok"] == "ASSEMBLY_EXECUTING"
end

#finished?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/transloadit/response/assembly.rb', line 36

def finished?
  aborted? || canceled? || completed? || error?
end

#rate_limit?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/transloadit/response/assembly.rb', line 44

def rate_limit?
  self["error"] == "RATE_LIMIT_REACHED"
end

#reload!Object



4
5
6
# File 'lib/transloadit/response/assembly.rb', line 4

def reload!
  replace Transloadit::Request.new(self["assembly_ssl_url"]).get
end

#reload_until_finished!(options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/transloadit/response/assembly.rb', line 54

def reload_until_finished!(options = {})
  tries = options[:tries] || DEFAULT_RELOAD_TRIES

  tries.times do
    sleep 1
    reload!
    return self if finished?
  end

  raise Transloadit::Exception::ReloadLimitReached
end

#replaying?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/transloadit/response/assembly.rb', line 32

def replaying?
  self["ok"] == "ASSEMBLY_REPLAYING"
end

#uploading?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/transloadit/response/assembly.rb', line 40

def uploading?
  self["ok"] == "ASSEMBLY_UPLOADING"
end

#wait_timeObject



48
49
50
# File 'lib/transloadit/response/assembly.rb', line 48

def wait_time
  self["info"]["retryIn"] || 0
end