Class: Twitorious::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/twitorious/notifier.rb

Instance Method Summary collapse

Constructor Details

#initializeNotifier

Returns a new instance of Notifier.



7
8
9
# File 'lib/twitorious/notifier.rb', line 7

def initialize
  @meow   = Meow.new("Twitorious")
end

Instance Method Details

#notify(sender, message, created, icon = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/twitorious/notifier.rb', line 11

def notify(sender, message, created, icon = nil)
  created = DateTime.parse(created)
  now     = DateTime.parse(Time.now.to_s).new_offset(created.offset)
  time_ago = Twitorious.time_ago_in_words(created, now, true)
  opts = {}
  opts[:icon] = icon if icon
  
  @meow.notify("#{sender} (#{time_ago})", message, opts) do
    urls = URI.extract(message, ['http', 'https'])
    urls.each do |url|
      %x{open #{url}}
    end
  end
end