Class: RecordingTS
- Inherits:
-
Object
- Object
- RecordingTS
- Defined in:
- lib/recording_ts.rb
Instance Method Summary collapse
- #delete! ⇒ Object
-
#initialize(recording) ⇒ RecordingTS
constructor
A new instance of RecordingTS.
- #process! ⇒ Object
Constructor Details
#initialize(recording) ⇒ RecordingTS
Returns a new instance of RecordingTS.
4 5 6 7 |
# File 'lib/recording_ts.rb', line 4 def initialize(recording) @parent = recording @target_file = nil end |
Instance Method Details
#delete! ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/recording_ts.rb', line 23 def delete!() begin puts "Removing file #{@target_file}" File.delete(@target_file) if @target_file rescue end end |
#process! ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/recording_ts.rb', line 8 def process!() @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 |