module AlarmCounter
Constants
- VERSION
Public Instance Methods
alarm()
click to toggle source
# File lib/alarm_counter.rb, line 4 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
counter()
click to toggle source
# File lib/alarm_counter.rb, line 39 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