Class: RecordingVDR
- Inherits:
-
Object
- Object
- RecordingVDR
- Defined in:
- lib/recording_vdr.rb
Instance Method Summary collapse
- #delete! ⇒ Object
-
#initialize(recording) ⇒ RecordingVDR
constructor
A new instance of RecordingVDR.
- #process! ⇒ Object
Constructor Details
#initialize(recording) ⇒ RecordingVDR
Returns a new instance of RecordingVDR.
2 3 4 5 |
# File 'lib/recording_vdr.rb', line 2 def initialize(recording) @parent = recording @target_file = nil end |
Instance Method Details
#delete! ⇒ Object
22 23 24 25 26 27 |
# File 'lib/recording_vdr.rb', line 22 def delete!() begin File.delete(@target_file) if @target_file rescue end end |
#process! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/recording_vdr.rb', line 6 def process!() return false @target_file = @parent.target_dir + "/#{@parent.friendly_name}.ts" FileDir.mkdirtree(@parent.target_dir) tf = File.new(@target_file, 'wb:ascii-8bit') source_files = Dir.glob("#{@parent.directory}/*.ts") source_files.sort! source_files.each { | source_file | sf = File.new(source_file, 'rb:ascii-8bit') while not sf.eof? tf.write(sf.read(1*(2**20))) # Only read some bytes at once sleep(0.01) # Be friendly to other processes end sf.close } end |