Changeset 1184
- Timestamp:
- 07/11/08 21:51:27 (6 months ago)
- Files:
-
- trunk/app/models/cast.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/models/cast.rb
r1121 r1184 1 1 class Cast < ActiveRecord::Base 2 2 belongs_to :document 3 3 4 4 FORMATS = %w(ogg mp3) 5 5 6 6 def update_file(format = "ogg") 7 7 puts "DEBUG: #{RAILS_ROOT}/bin/encode #{document.path} #{path(format)} #{format}" 8 8 system "#{RAILS_ROOT}/bin/encode", document.path, path(format), format 9 9 end 10 10 11 11 def before_destroy 12 12 FORMATS.each do |format| … … 18 18 "#{RAILS_ROOT}/media/cast/#{filename(format)}" 19 19 end 20 20 21 21 def filename(format = "ogg") 22 22 "#{id}.#{format}" 23 23 end 24 25 def size(format = "ogg") 26 File.size(path(format))24 25 def size(format = "ogg") 26 File.exists?(path(format)) ? File.size(path(format)) : 0 27 27 end 28 28 29 29 def uptodate?(format = "ogg") 30 30 FileUtils.uptodate?(path(format), document.path) 31 31 end 32 32 33 33 def self.update 34 34 Cast.find(:all).each do |cast| … … 42 42 end 43 43 end 44 44 45 45 Document.find(:all).delete_if { |d| !d.uploaded? or !d.casts.empty? }.each do |document| 46 46 puts "INFO: create cast for document #{document.id}"
