Class: PostIt::Notification
- Inherits:
-
Object
- Object
- PostIt::Notification
- Includes:
- Methadone::CLILogging, Methadone::Main, Methadone::SH
- Defined in:
- lib/post-it.rb
Instance Attribute Summary collapse
-
#subtitle ⇒ Object
Returns the value of attribute subtitle.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Notification
constructor
A new instance of Notification.
- #prepare(message, options = {}) ⇒ Object
- #send(message, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Notification
Returns a new instance of Notification.
14 15 16 17 18 19 20 21 22 |
# File 'lib/post-it.rb', line 14 def initialize(={}) @title = [:title] ? [:title] : 'Post It' @subtitle = [:subtitle] ? [:subtitle] : nil # Raise an exception if the Sticky Notifications app was not found unless File.exists?('/Applications/Sticky Notifications.app') raise "Sticky Notifications.app does not seem to be installed" end end |
Instance Attribute Details
#subtitle ⇒ Object
Returns the value of attribute subtitle.
12 13 14 |
# File 'lib/post-it.rb', line 12 def subtitle @subtitle end |
#title ⇒ Object
Returns the value of attribute title.
11 12 13 |
# File 'lib/post-it.rb', line 11 def title @title end |
Instance Method Details
#prepare(message, options = {}) ⇒ Object
44 45 46 47 |
# File 'lib/post-it.rb', line 44 def prepare(,={}) [:prepare] = true self.send(,) end |
#send(message, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/post-it.rb', line 26 def send(,={}) # Setup the default arguments for the SN url title = [:title] ? [:title] : self.title subtitle = [:subtitle] ? [:subtitle] : self.subtitle method = [:prepare] ? 'prepare' : 'note' # Build the URL scheme for sticky-notifications notifyurl = "sticky-notifications://#{method}?message=#{}&title=#{title}" notifyurl += "&subtitle=#{subtitle}" if subtitle # Via Methadone::SH (shell) run the open command to open the url. Raise an exception if there were errors begin sh "open '#{notifyurl}'" rescue Exception => e raise e. end end |