Sha256: bbe06bcf12bc9ddeea2b3903391d2b04872e698f32e1cf408683d60e18c7b2b7

Contents?: true

Size: 589 Bytes

Versions: 1

Compression:

Stored size: 589 Bytes

Contents

require 'thor'
require 'daemons'

require_relative "./time_alert/version"
require_relative "./cli"

module TimeAlert
  # Your code goes here...
  def self.alert(minutes)
    file_path = "/tmp/stop_alert"
    FileUtils.touch file_path
    Daemons.daemonize
    sleep minutes*60
    i = 0;
    while(File.exist? file_path) do
      #`say "bang bang bang"`
      system("say", "bang bang bang")

      sleep 0.5
      i += 1
      break if i > 100
    end
  end

  def self.stop
    begin
      File.delete "/tmp/stop_alert"
    rescue Errno::ENOENT => e
    end

  end
end
::CLI.start ARGV

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
time_alert-0.1.0 lib/time_alert.rb