module Teller

Constants

VERSION

Public Class Methods

silence!() click to toggle source

toggle silentness

# File lib/teller.rb, line 7
def self.silence!
  if @silenced
    @silenced = !@silenced
  else
    @silenced = true
  end
end
silent?() click to toggle source
# File lib/teller.rb, line 15
def self.silent?
  @silenced
end
tell(options) click to toggle source
# File lib/teller.rb, line 19
def self.tell(options)
  return false if @silenced

  if OS.mac?
    if options.is_a? Hash
      options.each do |arg, val|
      val.capitalize! if arg == :sound
      (args ||= "") << "-#{arg} \"#{val.to_s}\" "
    end

      args.strip!
    else
      args = "-message \"#{options.to_s}\""
    end

    `terminal-notifier #{args}`
  elsif OS.linux? or OS.unix?
    if options.is_a? String
      args = "\"#{options}\""
    else
      return false
    end

    `notify-send #{args}`
  else
    return false
  end
end