Class: Att

Inherits:
Object
  • Object
show all
Defined in:
lib/att.rb

Class Method Summary collapse

Class Method Details

.new_task(scheduled_time, command) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/att.rb', line 4

def self.new_task(scheduled_time, command)
	frozen_scheduled_time = Chronic.parse(scheduled_time)
	while true do
		puts "scheduled time is #{frozen_scheduled_time}"
		puts "current time is #{Time.now}"
#		binding.pry
		if Time.now >= frozen_scheduled_time
			puts "about to execute command '#{command}'"
    		output = `#{command}`
    		STDOUT.puts output
    		break
    	end
    	sleep(5)
    	STDOUT.puts "sleeping for 5 seconds..."
	end
end