Class: Radiodan::TouchFile
- Inherits:
-
Object
- Object
- Radiodan::TouchFile
- Includes:
- Logging
- Defined in:
- lib/radiodan/middleware/touch_file.rb
Instance Method Summary collapse
- #call(player) ⇒ Object
-
#initialize(config) ⇒ TouchFile
constructor
A new instance of TouchFile.
Methods included from Logging
included, level, level=, #logger, output, output=
Constructor Details
#initialize(config) ⇒ TouchFile
Returns a new instance of TouchFile.
13 14 15 |
# File 'lib/radiodan/middleware/touch_file.rb', line 13 def initialize(config) @path = config[:dir] end |
Instance Method Details
#call(player) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/radiodan/middleware/touch_file.rb', line 17 def call(player) EM::Synchrony.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 |