class Terminate::Options

Attributes

help[R]

Public Class Methods

new() click to toggle source
# File lib/terminate/options.rb, line 5
def initialize
  @help = ''
  @options = {}
  OptionParser.new do |opts|
    opts.banner = "Usage: wait_stop [pid] [options]"
    opts.on('-t', '--timeout=TIMEOUT', 'Timeout to kill(seconds, default is 10)') { |v| @options[:timeout] = v }
    opts.on('-s', '--signal=SIGNAL', 'SIGNAL to terminate(default TERM)') { |v| @options[:signal] = v }
    @help = opts.to_s
  end.parse!
end

Public Instance Methods

pid() click to toggle source
# File lib/terminate/options.rb, line 16
def pid
  ARGV[0].to_i
end
signal() click to toggle source
# File lib/terminate/options.rb, line 25
def signal
  @options[:signal] || 'TERM'
end
timeout() click to toggle source
# File lib/terminate/options.rb, line 20
def timeout
  timeout = @options[:timeout].to_i
  timeout <= 0 ? 10 : timeout
end