require 'open-uri' class Stock < ActiveRecord::Base # Get the current price of a stock def current_price url = "http://www2.dsm.com.qa/pps/dsm/portal/Pages/DSM_STOCK_DETAILS?id=" + self.ticker site = open( url ).read match = /(.+)<\/span>/.match( site ).captures match.to_s end end