Class: Script::Watch
- Inherits:
-
Object
- Object
- Script::Watch
- Defined in:
- lib/plugins/watch.rb
Instance Method Summary collapse
- #doit ⇒ Object
-
#initialize(toplevel, filename, &block) ⇒ Watch
constructor
A new instance of Watch.
-
#modify(&block) ⇒ Object
————————————————————— DSL.
Constructor Details
#initialize(toplevel, filename, &block) ⇒ Watch
10 11 12 13 14 15 |
# File 'lib/plugins/watch.rb', line 10 def initialize(toplevel, filename, &block) @toplevel = toplevel @filename = filename @notifier = INotify::Notifier.new instance_eval(&block) end |
Instance Method Details
#doit ⇒ Object
17 18 19 20 21 22 |
# File 'lib/plugins/watch.rb', line 17 def doit @notifier.to_io.tap do |io| rs, = IO.select([io], nil, nil, 0) @notifier.process if rs end end |
#modify(&block) ⇒ Object
DSL
26 27 28 29 30 31 |
# File 'lib/plugins/watch.rb', line 26 def modify(&block) @modify = Prog.new(@toplevel, &block) @notifier.watch(@filename, :modify) do @modify.doit end end |