class AfterNotifier::OptionParser

Attributes

pid[R]
terminal_notifier_options[R]

Public Class Methods

new(argv) click to toggle source
# File lib/after_notifier/option_parser.rb, line 9
def initialize(argv)
  @pid = argv.shift
  @terminal_notifier_options = argv

  raise OptionParseError, 'Required PID' unless valid_pid?

  # When unset -message option, set default message.
  unless @terminal_notifier_options.include?("-message")
    @terminal_notifier_options.push(*["-message", "AFTER_NOTIFIER"])
  end
end

Public Instance Methods

valid_pid?() click to toggle source
# File lib/after_notifier/option_parser.rb, line 21
def valid_pid?
  # PID is number above 0.
  @pid.to_i > 0
end