Class: Alki::Reload::ListenWatcher::Listener
- Inherits:
-
Object
- Object
- Alki::Reload::ListenWatcher::Listener
- Defined in:
- lib/alki/reload/listen_watcher.rb
Instance Method Summary collapse
-
#initialize(dirs, reloader) ⇒ Listener
constructor
A new instance of Listener.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(dirs, reloader) ⇒ Listener
Returns a new instance of Listener.
33 34 35 36 37 38 39 40 |
# File 'lib/alki/reload/listen_watcher.rb', line 33 def initialize(dirs,reloader) @count = 0 @listen = Listen.to(*dirs) do |modified, added, removed| if @count > 0 && (modified || added || removed) reloader.reload end end end |
Instance Method Details
#start ⇒ Object
42 43 44 45 46 47 |
# File 'lib/alki/reload/listen_watcher.rb', line 42 def start if @count == 0 @listen.start end @count += 1 end |
#stop ⇒ Object
49 50 51 |
# File 'lib/alki/reload/listen_watcher.rb', line 49 def stop @count -= 1 end |