class TRecs::RawFileStrategy
Attributes
clock[R]
file[R]
testing[R]
Public Class Methods
new(options={})
click to toggle source
# File lib/trecs/strategies/raw_file_strategy.rb, line 6 def initialize(options={}) file = options.fetch(:input_file) @file = File.open(file) @clock = options.fetch(:clock) { Time } @testing = options.fetch(:testing) { false } end
Public Instance Methods
custom_sleep(millis)
click to toggle source
# File lib/trecs/strategies/raw_file_strategy.rb, line 27 def custom_sleep(millis) if testing clock.sleep(millis) else @sleep_time ||= (millis/1000.0) sleep(@sleep_time) end end
perform()
click to toggle source
# File lib/trecs/strategies/raw_file_strategy.rb, line 14 def perform @recording = true start_time = clock.now while @recording current_time(timestamp(clock.now - start_time)) current_content(File.read(@file)) save_frame custom_sleep(recorder.step) end end
stop()
click to toggle source
# File lib/trecs/strategies/raw_file_strategy.rb, line 36 def stop @recording = false end
Private Instance Methods
timestamp(time)
click to toggle source
# File lib/trecs/strategies/raw_file_strategy.rb, line 45 def timestamp(time) (time * 1000).to_i end