Class: Sponges::Handler
- Inherits:
-
Object
- Object
- Sponges::Handler
- Extended by:
- Forwardable
- Defined in:
- lib/sponges/handler.rb
Instance Attribute Summary collapse
-
#notifier ⇒ Object
readonly
Returns the value of attribute notifier.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#supervisor ⇒ Object
readonly
Returns the value of attribute supervisor.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(supervisor) ⇒ Handler
constructor
A new instance of Handler.
- #push(signal) ⇒ Object
Constructor Details
Instance Attribute Details
#notifier ⇒ Object (readonly)
Returns the value of attribute notifier.
6 7 8 |
# File 'lib/sponges/handler.rb', line 6 def notifier @notifier end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
6 7 8 |
# File 'lib/sponges/handler.rb', line 6 def queue @queue end |
#supervisor ⇒ Object (readonly)
Returns the value of attribute supervisor.
6 7 8 |
# File 'lib/sponges/handler.rb', line 6 def supervisor @supervisor end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/sponges/handler.rb', line 22 def call Thread.new do while signal = @queue.gets do if Sponges::SIGNALS.include?(signal = find_signal(signal.chomp)) send "handler_#{signal.to_s.downcase}", signal end end end end |
#push(signal) ⇒ Object
18 19 20 |
# File 'lib/sponges/handler.rb', line 18 def push(signal) @notifier.puts(signal) end |