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
# File 'lib/jruby-notify/notify.rb', line 4

def initialize
  JRubyNotify.define_library_path
end

Instance Method Details

#runObject



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

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

#stopObject



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

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

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



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

def watch(paths, mask = JRubyNotify::FILE_ANY, subtree = true, &callback)
  @paths    = paths.kind_of?(Enumerable) ? paths : [paths]
  @callback = callback
  @mask     = mask
  @subtree  = subtree
end