Sha256: 4d6e1f130fefb828e74c1a1d99cc49e1335c921cdf2192f7183740f9d3d296e7
Contents?: true
Size: 853 Bytes
Versions: 6
Compression:
Stored size: 853 Bytes
Contents
class StockIndex class BaseScraper require 'nokogiri' def parse_rows(rows) rows.inject([]) do |array, tr| symbol = symbol(tr) market = market(tr) if symbol && market component = StockIndex::Component.new(symbol, market, wikipedia_link(tr)) array << component.attributes if component.valid? end array end end def td(tr, position) tr.css('td')[position] end def wikipedia_position(tr, position) wikipedia_td = tr.css('td')[position] wikipedia_path = wikipedia_td ? wikipedia_td.css('a').first.attributes['href'].value : nil build_wikipedia_link(wikipedia_path) end def build_wikipedia_link(wikipedia_path) URI::HTTP.build({:host => 'en.wikipedia.org', :path => wikipedia_path}).to_s rescue nil end end end
Version data entries
6 entries across 6 versions & 1 rubygems