Class: Loom::Trap::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/loom/trap.rb

Instance Method Summary collapse

Constructor Details

#initialize(&handler) ⇒ Handler

Returns a new instance of Handler.



31
32
33
34
# File 'lib/loom/trap.rb', line 31

def initialize(&handler)
  @signal_handle_counts = {}
  @handler = handler
end

Instance Method Details

#handle(signal) ⇒ Object



36
37
38
39
40
41
# File 'lib/loom/trap.rb', line 36

def handle(signal)
  @signal_handle_counts[signal] ||= 0
  @signal_handle_counts[signal] += 1

  @handler.call signal, @signal_handle_counts[signal]
end