Class: Send2MacClient::Listener
- Inherits:
-
Object
- Object
- Send2MacClient::Listener
- Defined in:
- lib/send2mac/listener.rb
Instance Method Summary collapse
-
#initialize ⇒ Listener
constructor
A new instance of Listener.
- #listen ⇒ Object
Constructor Details
#initialize ⇒ Listener
Returns a new instance of Listener.
7 8 9 |
# File 'lib/send2mac/listener.rb', line 7 def initialize @agent = Mechanize.new end |
Instance Method Details
#listen ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/send2mac/listener.rb', line 11 def listen puts "Listening..." loop do url = @agent.get("http://send2mac.com/get.php?APIKey=#{$api_key}").parser.xpath("//html/body/p").text unless (url =~ /\/\//).nil? url = url.gsub(/\r/,"") url = url.gsub(/\n/,"") puts url Launchy.open url.to_s else sleep 2 end end end |