Class: Polipus::PolipusSignalHandler

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/polipus.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePolipusSignalHandler

Returns a new instance of PolipusSignalHandler.



485
486
487
# File 'lib/polipus.rb', line 485

def initialize
  self.terminated = false
end

Instance Attribute Details

#terminatedObject

Returns the value of attribute terminated.



484
485
486
# File 'lib/polipus.rb', line 484

def terminated
  @terminated
end

Class Method Details

.enableObject



489
490
491
492
493
494
495
496
497
498
# File 'lib/polipus.rb', line 489

def self.enable
  trap(:INT)  {
    puts "Got INT signal"
    self.terminate
  }
  trap(:TERM) {
    puts "Got TERM signal"
    self.terminate
  }
end

.terminateObject



500
501
502
# File 'lib/polipus.rb', line 500

def self.terminate
  self.instance.terminated = true
end

.terminated?Boolean

Returns:

  • (Boolean)


504
505
506
# File 'lib/polipus.rb', line 504

def self.terminated?
  self.instance.terminated
end