Class: Tapas::Downloader
- Inherits:
-
Object
- Object
- Tapas::Downloader
- Defined in:
- lib/tapas/downloader.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#episode ⇒ Object
readonly
Returns the value of attribute episode.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#progress_bar ⇒ Object
readonly
Returns the value of attribute progress_bar.
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(episode, config) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(episode, config) ⇒ Downloader
Returns a new instance of Downloader.
8 9 10 11 12 |
# File 'lib/tapas/downloader.rb', line 8 def initialize(episode, config) @episode = episode @config = config @output = default_output(episode, config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/tapas/downloader.rb', line 6 def config @config end |
#episode ⇒ Object (readonly)
Returns the value of attribute episode.
6 7 8 |
# File 'lib/tapas/downloader.rb', line 6 def episode @episode end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
6 7 8 |
# File 'lib/tapas/downloader.rb', line 6 def output @output end |
#progress_bar ⇒ Object (readonly)
Returns the value of attribute progress_bar.
6 7 8 |
# File 'lib/tapas/downloader.rb', line 6 def @progress_bar end |
Instance Method Details
#download ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tapas/downloader.rb', line 14 def download open_opts = { http_basic_authentication: [config.username, config.password], content_length_proc: length_proc, progress_proc: progress_proc } open(episode.url, open_opts) do |download| File.open(output, 'wb') do |out| out.write download.read end end end |