Skip to content

Instantly share code, notes, and snippets.

@FernandoEscher
Forked from WA9ACE/price_check.rb
Created February 10, 2013 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FernandoEscher/4749755 to your computer and use it in GitHub Desktop.
Save FernandoEscher/4749755 to your computer and use it in GitHub Desktop.
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