Class: DownloadQueue
- Inherits:
-
Object
- Object
- DownloadQueue
- Defined in:
- lib/enigmamachine/download_queue.rb
Instance Method Summary collapse
-
#download_next_video ⇒ Object
Gets the next waiting_for_download Video from the database and starts downloading it.
-
#initialize ⇒ DownloadQueue
constructor
Adds a periodic timer to the Eventmachine reactor loop and immediately starts looking for videos to download.
Constructor Details
#initialize ⇒ DownloadQueue
Adds a periodic timer to the Eventmachine reactor loop and immediately starts looking for videos to download.
6 7 8 9 10 11 12 |
# File 'lib/enigmamachine/download_queue.rb', line 6 def initialize if EnigmaMachine.enable_http_downloads EM.add_periodic_timer(5) do download_next_video end end end |
Instance Method Details
#download_next_video ⇒ Object
Gets the next waiting_for_download Video from the database and starts downloading it.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/enigmamachine/download_queue.rb', line 18 def download_next_video if Video.waiting_for_download.count > 0 && Video.downloading.count == 0 video = Video.waiting_for_download.first begin video.download! rescue Exception => ex # don't do anything just yet, until we set up logging properly. end end end |