Class: J1::Utils::GracefulQuit
- Inherits:
-
Object
- Object
- J1::Utils::GracefulQuit
- Includes:
- Singleton
- Defined in:
- lib/j1/utils.rb
Instance Attribute Summary collapse
-
#breaker ⇒ Object
Returns the value of attribute breaker.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ GracefulQuit
constructor
A new instance of GracefulQuit.
Constructor Details
#initialize ⇒ GracefulQuit
Returns a new instance of GracefulQuit.
17 18 19 |
# File 'lib/j1/utils.rb', line 17 def initialize self.breaker = false end |
Instance Attribute Details
#breaker ⇒ Object
Returns the value of attribute breaker.
15 16 17 |
# File 'lib/j1/utils.rb', line 15 def breaker @breaker end |
Class Method Details
.check(message = "quitting") ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/j1/utils.rb', line 28 def self.check( = "quitting") if self.instance.breaker yield if block_given? puts exit end end |
.enable ⇒ Object
21 22 23 24 25 26 |
# File 'lib/j1/utils.rb', line 21 def self.enable trap('INT') { yield if block_given? self.instance.breaker = true } end |