Module: Nsnotify

Defined in:
lib/nsnotify/version.rb,
lib/nsnotify/nsnotify.rb

Constant Summary collapse

VERSION =
"0.0.4"
ICONS =
File.expand_path('../icons', __FILE__)
TERMINAL_NOTIFICATION_BIN =
File.join(vendor, 'terminal-notifier_v1.0/terminal-notifier.app/Contents/MacOS/terminal-notifier')

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.app_bundle_identifierObject

Returns the value of attribute app_bundle_identifier.



7
8
9
# File 'lib/nsnotify/nsnotify.rb', line 7

def app_bundle_identifier
  @app_bundle_identifier
end

.app_nameObject

Returns the value of attribute app_name.



7
8
9
# File 'lib/nsnotify/nsnotify.rb', line 7

def app_name
  @app_name
end

.useObject Also known as: use?

Returns the value of attribute use.



7
8
9
# File 'lib/nsnotify/nsnotify.rb', line 7

def use
  @use
end

Class Method Details

.notify(title, message) ⇒ Object

Calls the notification service.

Parameters

title<String>

the title of the notification

message<String>

the actual message

Example

Nsnotify.notify "Testing!", "Can you see me?!"


50
51
52
53
# File 'lib/nsnotify/nsnotify.rb', line 50

def notify(title, message)
  throw "This gem needs OSX 10.8 Mountain Lion to work!" if not usable?
  `'#{TERMINAL_NOTIFICATION_BIN}' #{Dir.pwd} '#{title}' '#{message}' '#{app_bundle_identifier}'`
end

.usable?Boolean

Determines whether you are running OS X 10.8 or later, which is the minimum required for the Notification Center.

Returns:

  • (Boolean)


13
14
15
# File 'lib/nsnotify/nsnotify.rb', line 13

def usable?
  @usable ||= `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
end