Class: Utilikilt::Watcher
- Inherits:
-
Object
- Object
- Utilikilt::Watcher
- Defined in:
- lib/utilikilt/watcher.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dir_to_watch, on_change_handler) ⇒ Watcher
constructor
A new instance of Watcher.
- #start_watching ⇒ Object
Constructor Details
#initialize(dir_to_watch, on_change_handler) ⇒ Watcher
Returns a new instance of Watcher.
9 10 11 12 13 14 |
# File 'lib/utilikilt/watcher.rb', line 9 def initialize( dir_to_watch, on_change_handler ) @fsevent = FSEvent.new @fsevent.watch dir_to_watch do |directories| on_change_handler.call( directories ) end end |
Class Method Details
.watch(dir_to_watch, &handler) ⇒ Object
5 6 7 |
# File 'lib/utilikilt/watcher.rb', line 5 def self.watch( dir_to_watch, &handler ) Watcher.new( dir_to_watch, handler ).start_watching end |
Instance Method Details
#start_watching ⇒ Object
16 17 18 |
# File 'lib/utilikilt/watcher.rb', line 16 def start_watching @fsevent.run end |