Module: Kernel
- Defined in:
- lib/system_control/growl.rb
Instance Method Summary (collapse)
-
- (Object) g(*args)
Sends a Growl Notification.
Instance Method Details
- (Object) g(*args)
Sends a Growl Notification. This method needs three arguments(two arguments are optional).
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/system_control/growl.rb', line 91 def g(*args) size = args.size raise ArgumentError, "wrong number of arguments" if size <= 0 || size > 3 case size when 1 title, description = "MacRuby", args[0] when 2, 3 title, description, opts = args[0 .. 2] if description.kind_of?(Hash) title, description, opts = "MacRuby", title, description end end opts = {} if opts.nil? raise ArgumentError, "illigal arguments" unless opts.kind_of?(Hash) g = System::Growl.instance icon = g.instance_variable_get(:@application_icon) if icon.nil? icon_path = File.(File.join(__FILE__, '../../../resources/macruby.icns')) icon = NSImage.alloc.initWithContentsOfFile(icon_path) end notification = 'notification' g.regist("MacRuby System Control", [notification], icon) g.notify(notification, title, description, opts) end |