Class: JRubyNotify::Notify
- Inherits:
-
Object
- Object
- JRubyNotify::Notify
- Defined in:
- lib/jruby-notify/notify.rb
Instance Method Summary collapse
-
#initialize ⇒ Notify
constructor
A new instance of Notify.
- #run ⇒ Object
- #stop ⇒ Object
- #watch(paths, mask = JRubyNotify::FILE_ANY, subtree = true, &callback) ⇒ Object
Constructor Details
#initialize ⇒ Notify
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
#run ⇒ Object
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 |
#stop ⇒ Object
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 |