-
-
Save FernandoEscher/4749755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
require 'terminal-notifier' | |
title = 'Bitcoin Gem' | |
activate = 'com.googlecode.iterm2' | |
current_price = 0 | |
while 1 | |
page = Nokogiri::HTML open('http://bitcoingem.com/') | |
h2 = page.at 'h2' | |
price = h2.to_s[/(\d+\.\d+)/, 1].to_f | |
if price == current_price | |
sleep 5 | |
elsif price > current_price | |
TerminalNotifier.notify("Price rose from #{current_price} to #{price}", :activate => activate, :title => title) | |
current_price = price | |
elsif price < current_price | |
TerminalNotifier.notify("Price dropped from #{current_price} to #{price}", :activate => activate, :title => title) | |
current_price = price | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment