Class: Thronglets::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/thronglets/listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeListener

Returns a new instance of Listener.



9
10
11
# File 'lib/thronglets/listener.rb', line 9

def initialize
  @process = nil
end

Instance Attribute Details

#processObject (readonly)

Returns the value of attribute process.



7
8
9
# File 'lib/thronglets/listener.rb', line 7

def process
  @process
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/thronglets/listener.rb', line 13

def run
  spawn_process

  listener = Listen.to("app") do |_modified, _added, _removed|
    process.stop
  ensure
    spawn_process
  end
  listener.start
  sleep
rescue Interrupt
  process.stop # tries increasingly harsher methods to kill the process.
end