Class: GrowlNotify
Defined Under Namespace
Classes: GrowlNotFound
Constant Summary collapse
- VERSION =
"0.0.3"
- PRE_1_3_APP =
"GrowlHelperApp"
- POST_1_3_APP =
"Growl"
Class Attribute Summary collapse
-
.application_name ⇒ Object
Returns the value of attribute application_name.
-
.default_notifications ⇒ Object
Returns the value of attribute default_notifications.
-
.icon ⇒ Object
Returns the value of attribute icon.
-
.notifications ⇒ Object
Returns the value of attribute notifications.
Class Method Summary collapse
- .application ⇒ Object
- .config(&block) ⇒ Object
- .emergency(options = {}) ⇒ Object
- .high(options = {}) ⇒ Object
- .moderate(options = {}) ⇒ Object
- .normal(options = {}) ⇒ Object
- .post1_3_app ⇒ Object
- .pre1_3_app ⇒ Object
- .register ⇒ Object
- .reset! ⇒ Object
- .send_notification(options = {}) ⇒ Object
- .sticky!(options = {}) ⇒ Object
- .very_low(options = {}) ⇒ Object
Class Attribute Details
.application_name ⇒ Object
Returns the value of attribute application_name.
11 12 13 |
# File 'lib/growl_notify.rb', line 11 def application_name @application_name end |
.default_notifications ⇒ Object
Returns the value of attribute default_notifications.
11 12 13 |
# File 'lib/growl_notify.rb', line 11 def default_notifications @default_notifications end |
.icon ⇒ Object
Returns the value of attribute icon.
11 12 13 |
# File 'lib/growl_notify.rb', line 11 def icon @icon end |
.notifications ⇒ Object
Returns the value of attribute notifications.
11 12 13 |
# File 'lib/growl_notify.rb', line 11 def notifications @notifications end |
Class Method Details
.application ⇒ Object
32 33 34 35 36 37 |
# File 'lib/growl_notify.rb', line 32 def application @application = pre1_3_app @application ||= post1_3_app raise GrowlNotFound if @application.nil? @application end |
.config(&block) ⇒ Object
17 18 19 20 |
# File 'lib/growl_notify.rb', line 17 def config(&block) block.call(self) register end |
.emergency(options = {}) ⇒ Object
81 82 83 84 |
# File 'lib/growl_notify.rb', line 81 def emergency(={}) .merge!(:priority => 2) send_notification() end |
.high(options = {}) ⇒ Object
76 77 78 79 |
# File 'lib/growl_notify.rb', line 76 def high(={}) .merge!(:priority => 1) send_notification() end |
.moderate(options = {}) ⇒ Object
66 67 68 69 |
# File 'lib/growl_notify.rb', line 66 def moderate(={}) .merge!(:priority => -1) send_notification() end |
.normal(options = {}) ⇒ Object
71 72 73 74 |
# File 'lib/growl_notify.rb', line 71 def normal(={}) .merge!(:priority => 0) send_notification() end |
.post1_3_app ⇒ Object
45 46 47 48 49 |
# File 'lib/growl_notify.rb', line 45 def post1_3_app app(POST_1_3_APP) rescue FindApp::ApplicationNotFoundError nil end |
.pre1_3_app ⇒ Object
39 40 41 42 43 |
# File 'lib/growl_notify.rb', line 39 def pre1_3_app app(PRE_1_3_APP) rescue FindApp::ApplicationNotFoundError nil end |
.register ⇒ Object
28 29 30 |
# File 'lib/growl_notify.rb', line 28 def register application.register(:all_notifications => @notifications, :as_application => @application_name, :default_notifications => @default_notifications) end |
.reset! ⇒ Object
22 23 24 25 26 |
# File 'lib/growl_notify.rb', line 22 def reset! [:application_name, :default_notifications, :notifications, :icon].each do |meth| send(:"#{meth}=", nil) end end |
.send_notification(options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/growl_notify.rb', line 51 def send_notification(= {}) defaults = {:title => 'no title', :application_name => @application_name, :description => 'no description', :sticky => false, :priority => 0, :with_name => notifications.first} local_icon = @icon local_icon = .delete(:icon) if .include?(:icon) if local_icon defaults.merge!(:image_from_location => local_icon) end application.notify(defaults.merge()) end |
.sticky!(options = {}) ⇒ Object
86 87 88 89 |
# File 'lib/growl_notify.rb', line 86 def sticky!(={}) .merge!(:sticky => true) send_notification() end |
.very_low(options = {}) ⇒ Object
61 62 63 64 |
# File 'lib/growl_notify.rb', line 61 def very_low(={}) .merge!(:priority => -2) send_notification() end |