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 7 |
# File 'lib/jruby-notify/notify.rb', line 4 def initialize JRubyNotify.define_library_path @watches = [] end |
Instance Method Details
#run ⇒ Object
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 |
#stop ⇒ Object
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 |