Class Snarl
In: lib/snarl.rb
Parent: Object
 Snarl (http://www.fullphat.net/snarl.html) is a simple notification system,
 similar to Growl under OSX. This is a simple pure Ruby wrapper to the

native API (using DL).

Methods

hide   id   new   send   send?   show   show_message   update   version   visible?  

Included Modules

SnarlAPI

Classes and Modules

Module Snarl::SnarlAPI

Constants

DEFAULT_TIMEOUT = 3
NO_TIMEOUT = 0

Public Class methods

Create a new snarl message, the only thing you need to send is a title note that if you decide to send an icon, you must provide the complete path. The timeout file has a default value (DEFAULT_TIMEOUT -> 3 seconds) but can be set to Snarl::NO_TIMEOUT, to force a manual acknowledgement of the notification.

[Source]

    # File lib/snarl.rb, line 80
80:   def initialize(title, msg=" ", icon=nil, timeout=DEFAULT_TIMEOUT)
81:     @ss = SnarlStruct.malloc
82:     show(title, msg, icon, timeout)
83:   end

a quick and easy method to create a new message, when you don’t care to access it again. Note that if you decide to send an icon, you must provide the complete path. The timeout file has a default value (DEFAULT_TIMEOUT -> 3 seconds) but can be set to Snarl::NO_TIMEOUT, to force a manual acknowledgement of the notification.

[Source]

    # File lib/snarl.rb, line 91
91:   def self.show_message(title, msg=" ", icon=nil, timeout=DEFAULT_TIMEOUT)
92:     Snarl.new(title, msg, icon, timeout)
93:   end

Return the current version of snarl (not the snarl gem) as a character string "1.0" format

[Source]

     # File lib/snarl.rb, line 128
128:   def self.version
129:     ss = SnarlAPI::SnarlStruct.malloc
130:     ss.cmd = SNARL_GET_VERSION
131:     version = SnarlAPI.send(ss)
132:     "#{version >> 16}.#{version & 0xffff}"
133:   end

Public Instance methods

Hide you message — this is the same as dismissing it

[Source]

     # File lib/snarl.rb, line 115
115:   def hide
116:     @ss.cmd = SNARL_HIDE
117:     send?
118:   end

Update an existing message, it will return true/false depending upon success (it will fail if the message has already timed out or been dismissed) Note that if you decide to send an icon, you must provide the complete path. The timeout file has a default value (DEFAULT_TIMEOUT -> 3 seconds) but can be set to Snarl::NO_TIMEOUT, to force a manual acknowledgement of the notification.

[Source]

     # File lib/snarl.rb, line 102
102:   def update(title,msg=" ",icon=nil, timeout=DEFAULT_TIMEOUT)
103:     @ss.cmd = SNARL_UPDATE
104:     @ss.title = SnarlAPI.to_cha(title)
105:     @ss.text = SnarlAPI.to_cha(msg)
106:     if icon
107:       icon = File.expand_path(icon)
108:       @ss.icon = SnarlAPI.to_cha(icon) if File.exist?(icon.to_s)
109:     end
110:     @ss.timeout = timeout
111:     send?    
112:   end

Check to see if the message is still being displayed

[Source]

     # File lib/snarl.rb, line 121
121:   def visible?
122:     @ss.cmd = SNARL_IS_VISIBLE
123:     send?
124:   end

Protected Instance methods

Return the internal snarl id

[Source]

     # File lib/snarl.rb, line 137
137:   def id
138:     @ss.id
139:   end

Send the snarl structure, return the unfiltered result

[Source]

     # File lib/snarl.rb, line 156
156:   def send
157:     SnarlAPI.send(@ss)
158:   end

Send the snarl structure, return a true/false (interpreted from snarl)

[Source]

     # File lib/snarl.rb, line 161
161:   def send?
162:     !send.zero?
163:   end

exactly like the contructor — this will create a new message, loosing the original

[Source]

     # File lib/snarl.rb, line 143
143:   def show(title,msg=" ", icon=nil, timeout=DEFAULT_TIMEOUT)
144:     @ss.title = SnarlAPI.to_cha(title)
145:     @ss.text = SnarlAPI.to_cha(msg)
146:     if icon
147:       icon = File.expand_path(icon)
148:       @ss.icon = SnarlAPI.to_cha(icon) if File.exist?(icon.to_s)
149:     end
150:     @ss.timeout = timeout
151:     @ss.cmd = SNARL_SHOW
152:     @ss.id = send
153:   end

[Validate]