Class: Vimeo::Advanced::SimpleUpload::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/vimeo/advanced/simple_upload/task.rb

Constant Summary collapse

CHUNK_SIZE =

2 megabytes

2 * 1024 * 1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vimeo, oauth_consumer, io, size, filename) ⇒ Task

Returns a new instance of Task.



12
13
14
15
16
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 12

def initialize(vimeo, oauth_consumer, io, size, filename)
  @vimeo, @oauth_consumer = vimeo, oauth_consumer
  @io, @size, @filename = io, size, filename
  @chunks = []
end

Instance Attribute Details

#chunksObject (readonly)

Returns the value of attribute chunks.



9
10
11
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 9

def chunks
  @chunks
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



9
10
11
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 9

def endpoint
  @endpoint
end

#filenameObject (readonly)

Returns the value of attribute filename.



8
9
10
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 8

def filename
  @filename
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 10

def id
  @id
end

#ioObject (readonly)

Returns the value of attribute io.



8
9
10
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 8

def io
  @io
end

#oauth_consumerObject (readonly)

Returns the value of attribute oauth_consumer.



7
8
9
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 7

def oauth_consumer
  @oauth_consumer
end

#sizeObject (readonly)

Returns the value of attribute size.



8
9
10
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 8

def size
  @size
end

#video_idObject (readonly)

Returns the value of attribute video_id.



10
11
12
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 10

def video_id
  @video_id
end

#vimeoObject (readonly)

Returns the value of attribute vimeo.



7
8
9
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 7

def vimeo
  @vimeo
end

Instance Method Details

#executeObject

Uploads the file to Vimeo and returns the video_id on success.

Raises:



19
20
21
22
23
24
25
26
27
# File 'lib/vimeo/advanced/simple_upload/task.rb', line 19

def execute
  check_quota
  authorize
  upload
  raise UploadError.new, "Validation of chunks failed." unless valid?
  complete

  return video_id
end