Class: Utilikilt::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/utilikilt/watcher.rb

Class Method Summary collapse

Instance Method Summary collapse

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_watchingObject



16
17
18
# File 'lib/utilikilt/watcher.rb', line 16

def start_watching
  @fsevent.run
end