Class: Timmy::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/timmy/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(replay_speed:) ⇒ Runner

Returns a new instance of Runner.



20
21
22
23
# File 'lib/timmy/runner.rb', line 20

def initialize(replay_speed:)
  @replay_speed = replay_speed
  @last_replay_time = 0
end

Class Method Details

.runObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/timmy/runner.rb', line 8

def run
  ConfigLoader.load

  options = OptionParser.parse
  replay_speed = options[:replay_speed] || @replay_speed
  Logger.set_precision(options[:precision]) if options.key?(:precision)
  Logger.set_profile(options[:profile]) if options.key?(:profile)

  self.new(replay_speed: replay_speed).consume_stdin
end

.set_replay_speed(speed) ⇒ Object



4
5
6
# File 'lib/timmy/runner.rb', line 4

def set_replay_speed(speed)
  @replay_speed = speed
end

Instance Method Details

#consume_stdinObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/timmy/runner.rb', line 25

def consume_stdin
  around_run_lines do
    STDIN.each_line do |line|
      next if init_replay_mode(line)

      if @replay_mode
        replay_line(line)
      else
        run_line(line.rstrip)
      end
    end

    Logger.put_eof unless @replay_mode
  end
end