Sha256: 665ddf5e2063624dd0777a449089483659fb662959a3f37476b5a00fc4adfb15

Contents?: true

Size: 630 Bytes

Versions: 4

Compression:

Stored size: 630 Bytes

Contents

=begin
Controls the radio by touching files.

This class looks for matching files in 
a given directory. When the file exists,
the corresponding event is triggered and
the file deleted.
=end

class Radiodan
class TouchFile
  include Logging  
  def initialize(config)
    @path = config[:dir]
  end

  def call(player)
    EM.now_and_every(0.5) do
      player.events.each do |event|
        file = event.to_s
        p = Pathname.new(File.join(@path, file))
        if p.exist?
          logger.debug "Responding to file #{file}"
          p.delete
          player.trigger_event file
        end
      end
    end
  end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
radiodan-0.0.4 lib/radiodan/middleware/touch_file.rb
radiodan-0.0.3 lib/radiodan/middleware/touch_file.rb
radiodan-0.0.2 lib/radiodan/middleware/touch_file.rb
radiodan-0.0.1 lib/radiodan/middleware/touch_file.rb