Class: Video

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/enigmamachine/models/video.rb

Overview

A video which we want to encode.

Class Method Summary collapse

Class Method Details

.completeObject

Named scope giving back all videos which have completed encoding.



104
105
106
# File 'lib/enigmamachine/models/video.rb', line 104

def self.complete
  all(:state => 'complete', :order => [:updated_at.desc])
end

.downloadingObject

Named scope returning all videos which currently downloading.



116
117
118
# File 'lib/enigmamachine/models/video.rb', line 116

def self.downloading
  all(:state => 'downloading')
end

.encodingObject

Named scope for all videos which are currently encoding. Theoretically there should only ever be one.



92
93
94
# File 'lib/enigmamachine/models/video.rb', line 92

def self.encoding
  all(:state => 'encoding')
end

.reset_downloading_videosObject



133
134
135
136
137
# File 'lib/enigmamachine/models/video.rb', line 133

def self.reset_downloading_videos
  Video.downloading.each do |video|
    video.reset_download!
  end
end

.reset_encoding_videosObject

Resets all videos currently marked as “encoding” to state “unencoded” which is the initial state.

If any videos are marked as “encoding” when the application starts, presumably due to an encoding interruption in the last session, they should be reset.



127
128
129
130
131
# File 'lib/enigmamachine/models/video.rb', line 127

def self.reset_encoding_videos
  Video.encoding.each do |video|
    video.reset!
  end
end

.unencodedObject

Named scope for all videos which are waiting to start encoding.



85
86
87
# File 'lib/enigmamachine/models/video.rb', line 85

def self.unencoded
  all(:state => 'unencoded')
end

.waiting_for_downloadObject

Named scope returning all videos which are not yet downloaded.



110
111
112
# File 'lib/enigmamachine/models/video.rb', line 110

def self.waiting_for_download
  all(:state => 'waiting_for_download')
end

.with_encode_errorsObject

Named scope giving back all videos with encoding errors.



98
99
100
# File 'lib/enigmamachine/models/video.rb', line 98

def self.with_encode_errors
  all(:state => 'encode_error')
end