Class: JRubyNotify::Notify

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby-notify/notify.rb

Instance Method Summary collapse

Constructor Details

#initializeNotify

Returns a new instance of Notify.



4
5
6
7
# File 'lib/jruby-notify/notify.rb', line 4

def initialize
  JRubyNotify.define_library_path
  @watches = []
end

Instance Method Details

#runObject



16
17
18
19
20
# File 'lib/jruby-notify/notify.rb', line 16

def run
  @watches = @paths.inject([]) do |watches, path|
    watches << Java::NetContentobjectsJNotify::JNotify.addWatch(path, @mask, @subtree, JRubyNotify::Listener.new(@callback))
  end
end

#stopObject



22
23
24
# File 'lib/jruby-notify/notify.rb', line 22

def stop
  @watches.each { |watch| Java::NetContentobjectsJNotify::JNotify.removeWatch(watch) }
end

#watch(paths, mask = JRubyNotify::FILE_ANY, subtree = true, &callback) ⇒ Object



9
10
11
12
13
14
# File 'lib/jruby-notify/notify.rb', line 9

def watch(paths, mask = JRubyNotify::FILE_ANY, subtree = true, &callback)
  @paths    = Array(paths)
  @callback = callback
  @mask     = mask
  @subtree  = subtree
end