Sha256: f2154c0f7dddf452bf4263bfeea56d80c1af5d79b72e09dd577d4edb25b91655
Contents?: true
Size: 750 Bytes
Versions: 2
Compression:
Stored size: 750 Bytes
Contents
class Radiodan class Panic include Logging def initialize(config) @panic = false @timeout = config.delete(:duration).to_i @playlist = config[:playlist] end def call(player) @player = player @player.register_event :panic do panic! end end def panic? @panic == true end def panic! return true if panic? @panic = true original_state = @player.playlist logger.debug "panic for #{@timeout} seconds" @player.playlist = @playlist EM::Synchrony.add_timer(@timeout) do return_to_state original_state end end def return_to_state(playlist) logger.debug "calming" @panic = false @player.playlist = playlist end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
radiodan-1.0.1 | lib/radiodan/middleware/panic.rb |
radiodan-1.0.0 | lib/radiodan/middleware/panic.rb |