Class: Adva::Static::Server::Watch::Handler
- Inherits:
-
Object
- Object
- Adva::Static::Server::Watch::Handler
- Includes:
- Observable
- Defined in:
- lib/adva/static/server/watch/handler.rb
Instance Method Summary collapse
-
#initialize(observable, pattern) ⇒ Handler
constructor
A new instance of Handler.
- #listen ⇒ Object
- #trigger ⇒ Object
Constructor Details
#initialize(observable, pattern) ⇒ Handler
Returns a new instance of Handler.
10 11 12 13 14 15 |
# File 'lib/adva/static/server/watch/handler.rb', line 10 def initialize(observable, pattern) add_observer(observable) @pattern = pattern @current = Dir[pattern] @mtime = Time.now end |
Instance Method Details
#listen ⇒ Object
17 18 19 |
# File 'lib/adva/static/server/watch/handler.rb', line 17 def listen loop { trigger; sleep(0.5) } end |
#trigger ⇒ Object
21 22 23 24 25 26 |
# File 'lib/adva/static/server/watch/handler.rb', line 21 def trigger events.each do |path, event| changed(true) notify_observers(path.dup, event) end end |