class TRecs::WatchFileTicker

Attributes

player[RW]

Public Class Methods

new(opts={}) click to toggle source
# File lib/trecs/tickers/watch_file_ticker.rb, line 5
def initialize(opts={})
  @watch_file = opts.fetch(:ticker_file)
  FileUtils.touch(@watch_file)
  File.open(@watch_file, "w") do |f|
    f.write("0")
  end
  @step = opts.fetch(:step)
end

Public Instance Methods

inspect()
Alias for: to_s
start() click to toggle source
# File lib/trecs/tickers/watch_file_ticker.rb, line 14
def start
  while input =~ /\A[0-9]+\Z/
    time = input.to_i
    player.tick(time)
    sleep(@step/1000.0)
  end
end
to_s() click to toggle source
# File lib/trecs/tickers/watch_file_ticker.rb, line 21
def to_s
  "<#{self.class}>"
end
Also aliased as: inspect

Private Instance Methods

input() click to toggle source
# File lib/trecs/tickers/watch_file_ticker.rb, line 26
def input
  File.read(@watch_file).chomp
end