Class: AptControl::CLI::Root::FSListenerFactory
- Inherits:
-
Object
- Object
- AptControl::CLI::Root::FSListenerFactory
- Defined in:
- lib/apt_control/cli.rb
Instance Attribute Summary collapse
-
#disable_inotify ⇒ Object
readonly
Returns the value of attribute disable_inotify.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ FSListenerFactory
constructor
A new instance of FSListenerFactory.
- #new(dir, pattern, &on_change) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ FSListenerFactory
Returns a new instance of FSListenerFactory.
194 195 196 |
# File 'lib/apt_control/cli.rb', line 194 def initialize(={}) @disable_inotify = [:disable_inotify] end |
Instance Attribute Details
#disable_inotify ⇒ Object (readonly)
Returns the value of attribute disable_inotify.
192 193 194 |
# File 'lib/apt_control/cli.rb', line 192 def disable_inotify @disable_inotify end |
Instance Method Details
#new(dir, pattern, &on_change) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/apt_control/cli.rb', line 198 def new(dir, pattern, &on_change) Listen.to(dir).filter(pattern).tap do |listener| if disable_inotify listener.force_polling(true) listener.(false) else listener.force_adapter(Listen::Adapters::Linux) end listener.change(&on_change) end end |