Class: Whenever::CommandLine
- Inherits:
-
Object
- Object
- Whenever::CommandLine
- Defined in:
- lib/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.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/command_line.rb', line 8 def initialize(={}) = [:file] ||= 'config/schedule.rb' [:identifier] ||= default_identifier unless File.exists?([:file]) warn("[fail] Can't find file: #{@options[:file]}") exit(1) end if [:update] && [:write] warn("[fail] Can't update AND write. choose one.") exit(1) end end |
Class Method Details
.execute(options = {}) ⇒ Object
4 5 6 |
# File 'lib/command_line.rb', line 4 def self.execute(={}) new().run end |
Instance Method Details
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/command_line.rb', line 25 def run if [:update] write_crontab(updated_crontab) elsif [:write] write_crontab(whenever_cron) else puts Whenever.cron() exit end end |