Class: Guard::LiveReload::Reactor
- Inherits:
-
Object
- Object
- Guard::LiveReload::Reactor
- Defined in:
- lib/guard/livereload/reactor.rb
Instance Attribute Summary collapse
-
#connections_count ⇒ Object
readonly
Returns the value of attribute connections_count.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
-
#web_sockets ⇒ Object
readonly
Returns the value of attribute web_sockets.
Instance Method Summary collapse
-
#initialize(options) ⇒ Reactor
constructor
A new instance of Reactor.
- #reload_browser(paths = []) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options) ⇒ Reactor
Returns a new instance of Reactor.
8 9 10 11 12 13 |
# File 'lib/guard/livereload/reactor.rb', line 8 def initialize() @web_sockets = [] @options = @thread = Thread.new { _start_reactor } @connections_count = 0 end |
Instance Attribute Details
#connections_count ⇒ Object (readonly)
Returns the value of attribute connections_count.
6 7 8 |
# File 'lib/guard/livereload/reactor.rb', line 6 def connections_count @connections_count end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/guard/livereload/reactor.rb', line 6 def @options end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
6 7 8 |
# File 'lib/guard/livereload/reactor.rb', line 6 def thread @thread end |
#web_sockets ⇒ Object (readonly)
Returns the value of attribute web_sockets.
6 7 8 |
# File 'lib/guard/livereload/reactor.rb', line 6 def web_sockets @web_sockets end |
Instance Method Details
#reload_browser(paths = []) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/guard/livereload/reactor.rb', line 19 def reload_browser(paths = []) msg = "Reloading browser: #{paths.join(' ')}" Compat::UI.info msg if [:notify] Compat::UI.notify(msg, title: 'Reloading browser', image: :success) end paths.each do |path| data = _data(path) Compat::UI.debug(data) web_sockets.each { |ws| ws.send(MultiJson.encode(data)) } end end |
#stop ⇒ Object
15 16 17 |
# File 'lib/guard/livereload/reactor.rb', line 15 def stop thread.kill end |