Class: Whenever::CommandLine
- Inherits:
-
Object
- Object
- Whenever::CommandLine
- Defined in:
- lib/whenever/command_line.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CommandLine
Returns a new instance of CommandLine.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/whenever/command_line.rb', line 11 def initialize(={}) @options = @options[:file] ||= 'config/schedule.rb' @options[:cut] ||= 0 @options[:identifier] ||= default_identifier unless File.exists?(@options[:file]) warn("[fail] Can't find file: #{@options[:file]}") exit(1) end if [@options[:update], @options[:write], @options[:clear]].compact.length > 1 warn("[fail] Can only update, write or clear. Choose one.") exit(1) end unless @options[:cut].to_s =~ /[0-9]*/ warn("[fail] Can't cut negative lines from the crontab #{[:cut]}") exit(1) end @options[:cut] = @options[:cut].to_i end |
Class Method Details
.execute(options = {}) ⇒ Object
7 8 9 |
# File 'lib/whenever/command_line.rb', line 7 def self.execute(={}) new().run end |