Sha256: d588b46cb66d6c7ae3678c56e640fe94296f656ea41954f9d460a5870ee35f54

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require "alarm_counter/version"

module AlarmCounter
	def alarm
		system('clear')
		puts 'What time do you want your alarm?'
		puts 'Input Year'
		e = gets.to_i
		puts 'Input Month'
		f = gets.to_i
		puts 'Input Date'
		g = gets.to_i
		puts 'Input Hour(24 Hour format)'
		i = gets.to_i
		puts 'Input Minute'
		j = gets.to_i

		a = Time.new(e, f, g, i, j, 0, "+05:30")

		loop do
			b = Time.now
			c = a-b
			puts 'Alarm Clock'
			puts "Current time :#{b}"	
			puts "Seconds left :#{c}"
			sleep(0.05)
			system('clear')

			if c > -0.1 && c < 0.1
				puts "Time elapsed"
				sleep(2)
				system('clear')
		#system('cvlc "burn.mp3"')
		break
	    end
    end
end

def counter
	system('clear')

	puts "How much time do you want to count?"
	d = gets.to_i

	puts 'To count in seconds press (1)
	For minutes press (2)
	For Hours Press (3)'
	f = gets.to_i
	if f == 1
		puts 'Seconds selected'
	end
	if f == 2
		puts 'Minutes selected'
		d = d*60
	end
	if f == 3
		puts 'Hours selected'
		d = d*3600
	else
		puts 'Invalid Input'
	end

	c = Time.now
	
	loop do
		system('clear')
		b = Time.now
		a = b - c
		e = d - a
		puts 'Countdown timer'
		puts "Seconds left #{e}"
		sleep(0.05)

		if e > -0.1 && e < 0.1
			puts "Count elapsed"
			sleep(2)
			system('clear')
		#system('cvlc "burn.mp3"')
		break
	    end
    end
end

system('clear')

puts "For alarm press (1)
For Counter press (2)
For Just the time press (3)"

a = gets.to_i

if a == 1
	alarm
end

if a == 2
	counter
end

if a == 3
	loop do
		system('clear')
		puts "The time is :#{Time.now}"
		sleep(0.05)
	end
else
	puts 'Invalid Input'
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alarm_counter-1.0.1 lib/alarm_counter.rb
alarm_counter-1.0.0 lib/alarm_counter.rb