Class: Pige::Client::Chunk
- Defined in:
- lib/pige/client/chunk.rb
Instance Attribute Summary collapse
-
#begin ⇒ Object
Returns the value of attribute begin.
-
#completion_rate ⇒ Object
Returns the value of attribute completion_rate.
-
#end ⇒ Object
Returns the value of attribute end.
-
#format ⇒ Object
Returns the value of attribute format.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from Resource
#created_at, #errors, #id, #source_id, #updated_at
Instance Method Summary collapse
Methods inherited from Resource
all, base_url, create, #destroy, destroy, destroy_all, #initialize, older_than, #older_than?, resource_name, resources_name, time_attribute
Constructor Details
This class inherits a constructor from Pige::Client::Resource
Instance Attribute Details
#begin ⇒ Object
Returns the value of attribute begin.
4 5 6 |
# File 'lib/pige/client/chunk.rb', line 4 def begin @begin end |
#completion_rate ⇒ Object
Returns the value of attribute completion_rate.
4 5 6 |
# File 'lib/pige/client/chunk.rb', line 4 def completion_rate @completion_rate end |
#end ⇒ Object
Returns the value of attribute end.
4 5 6 |
# File 'lib/pige/client/chunk.rb', line 4 def end @end end |
#format ⇒ Object
Returns the value of attribute format.
4 5 6 |
# File 'lib/pige/client/chunk.rb', line 4 def format @format end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/pige/client/chunk.rb', line 4 def title @title end |
Instance Method Details
#download(target) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pige/client/chunk.rb', line 26 def download(target) target_file = File.join(target, download_file) File.open(target_file, "w") do |file| open(download_url) do |url| IO.copy_stream url, file end end target_file end |
#download_file ⇒ Object
22 23 24 |
# File 'lib/pige/client/chunk.rb', line 22 def download_file "#{title}.#{extension}" end |
#download_url ⇒ Object
18 19 20 |
# File 'lib/pige/client/chunk.rb', line 18 def download_url "#{Pige::Client.box_url}/sources/1/chunks/#{id}.#{extension}" end |
#extension ⇒ Object
14 15 16 |
# File 'lib/pige/client/chunk.rb', line 14 def extension format == "vorbis" ? "ogg" : format end |