Class: Autometal::Growl
- Inherits:
-
Object
- Object
- Autometal::Growl
- Defined in:
- lib/growl.rb
Overview
Creates a Growl notification with a custom title and body. Depends on Bob Harris’ growl Shell script http://hints.macworld.com/dlfiles/growl_sh.txt
You will need to download, install, make executable and include the script path in your path.
Refer to http://hints.macworld.com/dlfiles/growl_sh.txt
for installation details
Available options:
:sticky: Make a sticky notification. Default is false
:title: Notification title. Defaults to 'Script Notification'
Example
notification = Autometal::Growl.new(msg, :title => "Welcome to Sky Valley")
notification.transmit!
Constant Summary collapse
- VERSION =
"1.0.1"
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#sticky ⇒ Object
Returns the value of attribute sticky.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #cmd_path ⇒ Object
-
#initialize(body, opts = {}) ⇒ Growl
constructor
A new instance of Growl.
- #transmit! ⇒ Object
Constructor Details
#initialize(body, opts = {}) ⇒ Growl
Returns a new instance of Growl.
32 33 34 35 36 37 |
# File 'lib/growl.rb', line 32 def initialize body, opts = {} raise ArgumentError.new("Please provide a notification body") if [nil, false, ""].include?(body) @title = opts.delete(:title) || "Script notification" @body = body @sticky = opts[:sticky] == nil ? true : opts.delete(:sticky) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
26 27 28 |
# File 'lib/growl.rb', line 26 def body @body end |
#sticky ⇒ Object
Returns the value of attribute sticky.
26 27 28 |
# File 'lib/growl.rb', line 26 def sticky @sticky end |
#title ⇒ Object
Returns the value of attribute title.
26 27 28 |
# File 'lib/growl.rb', line 26 def title @title end |
Instance Method Details
#cmd_path ⇒ Object
28 29 30 |
# File 'lib/growl.rb', line 28 def cmd_path File.join("/","usr","local","bin","growl") end |
#transmit! ⇒ Object
39 40 41 42 |
# File 'lib/growl.rb', line 39 def transmit! response = execute_shell_command raise Autometal::GrowlException.new unless response end |