Class: Droonga::FileObserver
- Inherits:
-
Object
- Object
- Droonga::FileObserver
- Defined in:
- lib/droonga/file_observer.rb
Constant Summary collapse
- CHECK_INTERVAL =
1
Instance Method Summary collapse
-
#initialize(loop, path) ⇒ FileObserver
constructor
A new instance of FileObserver.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(loop, path) ⇒ FileObserver
Returns a new instance of FileObserver.
31 32 33 34 35 36 37 38 39 |
# File 'lib/droonga/file_observer.rb', line 31 def initialize(loop, path) @loop = loop @path = path if @path.exist? @mtime = @path.mtime else @mtime = nil end end |
Instance Method Details
#start ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/droonga/file_observer.rb', line 41 def start return if @timer @timer = Coolio::TimerWatcher.new(CHECK_INTERVAL, true) @timer.on_timer do if updated? @mtime = @path.mtime on_change end end @loop.attach(@timer) logger.trace("start: timer attached", :watcher => @timer, :path => @path) end |
#stop ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/droonga/file_observer.rb', line 56 def stop @timer.detach if @timer logger.trace("stop: timer detached", :watcher => @timer, :path => @path) @timer = nil end |