Class: Pair::Notification::OSXDispatcher
- Inherits:
-
Dispatcher
- Object
- Dispatcher
- Pair::Notification::OSXDispatcher
- Defined in:
- lib/pair/notification/o_s_x_dispatcher.rb
Constant Summary collapse
- NOTIFICATIONS =
[{:name => "Session Events", :enabled => true}]
Instance Attribute Summary collapse
-
#app_icon ⇒ Object
readonly
Returns the value of attribute app_icon.
-
#growl ⇒ Object
readonly
Returns the value of attribute growl.
Attributes inherited from Dispatcher
Instance Method Summary collapse
- #gntp_notify(options) ⇒ Object
-
#initialize(options = {}) ⇒ OSXDispatcher
constructor
A new instance of OSXDispatcher.
- #register_growl ⇒ Object
- #session_join(user, session) ⇒ Object
- #session_part(user, session) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ OSXDispatcher
Returns a new instance of OSXDispatcher.
10 11 12 13 14 15 16 17 18 |
# File 'lib/pair/notification/o_s_x_dispatcher.rb', line 10 def initialize( = {}) @app_icon = .delete(:app_icon) super register_growl if Pair.config.growl_enabled? rescue Errno::ECONNREFUSED => except raise Pair::Notification::GNTPError.new("Growl notification transfer protocol is not enabled, either start growl or disable growl via pair config") end |
Instance Attribute Details
#app_icon ⇒ Object (readonly)
Returns the value of attribute app_icon.
6 7 8 |
# File 'lib/pair/notification/o_s_x_dispatcher.rb', line 6 def app_icon @app_icon end |
#growl ⇒ Object (readonly)
Returns the value of attribute growl.
6 7 8 |
# File 'lib/pair/notification/o_s_x_dispatcher.rb', line 6 def growl @growl end |
Instance Method Details
#gntp_notify(options) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pair/notification/o_s_x_dispatcher.rb', line 42 def gntp_notify() if enabled if block_given? yield @growl end if [:text] = { :name => "Session Events", :title => "", :icon => @app_icon, :sticky => false }.merge() @growl.notify() end end end |
#register_growl ⇒ Object
20 21 22 23 |
# File 'lib/pair/notification/o_s_x_dispatcher.rb', line 20 def register_growl @growl = GNTP.new(Pair::APPLICATION_NAME) @growl.register application_hash end |
#session_join(user, session) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/pair/notification/o_s_x_dispatcher.rb', line 25 def session_join(user, session) gntp_notify({ :name => "Session Events", :title => "Pair Message", :text => "#{user} joined session \"#{session}\"", :icon => Pair::ICON_SESSION_JOIN, :sticky => true }) end |
#session_part(user, session) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/pair/notification/o_s_x_dispatcher.rb', line 33 def session_part(user, session) gntp_notify({ :name => "Session Events", :title => "Pair Message", :text => "#{user} parted session \"#{session}\"", :icon => Pair::ICON_SESSION_JOIN, :sticky => true }) end |