class Bitprice::Listing

Attributes

high[RW]
last_price[RW]
low[RW]
marketcap[RW]
name[RW]
numcoins[RW]
percent[RW]
ticker[RW]
url[RW]
volume[RW]

Public Class Methods

now() click to toggle source
# File lib/bitprice/listing.rb, line 7
def self.now
  self.scrape_world_coin_index
  self.scrape_crypto
end
scrape_crypto() click to toggle source
# File lib/bitprice/listing.rb, line 13
def self.scrape_crypto
 @@all
end
scrape_world_coin_index() click to toggle source
# File lib/bitprice/listing.rb, line 19
def self.scrape_world_coin_index


  doc = Nokogiri::HTML(open("https://www.worldcoinindex.com"))
  
  counter = 0

  @coinname = []
  @percentage = []
  @high = []
  @low = []

  @tic = []
  @lastp = []
  @volum = []
  @numbercoins = []
  @marketc = []


   doc.css(".bitcoinName h1 span").each do |coin|
    @coinname << coin.text
   end

    doc.css(".percentage span").each do |per|
    @percentage << per.text
   end

   doc.css(".highprice .span").each do |up|
    @high << up.text
   end

   doc.css(".lowprice .span").each do |down|
    @low << down.text
   end

   doc.css(".ticker h2").each do |tick|
    @tic << tick.text
   end

   doc.css(".lastprice .span").each do |last|
    @lastp << last.text
   end

    doc.css(".volume .span").each do |vol|
    @volum << vol.text.strip
   end

   doc.css(".volume .span").each do |num|
    @numbercoins << num.text.strip
   end

    doc.css(".marketcap .span").each do |mar|
    @marketc << mar.text.strip
   end

while counter < 100
  
    crypto_info = self.new
    crypto_info.name = @coinname[counter]
    crypto_info.url = "coin/" + @coinname[counter]
    crypto_info.percent = @percentage[counter]
    crypto_info.high = @high[counter]  
    crypto_info.low = @low[counter]
    crypto_info.ticker = @tic[counter]   
    crypto_info.last_price = @lastp[counter]
    crypto_info.volume = @volum[counter]
    crypto_info.numcoins = @numbercoins[counter]
    crypto_info.marketcap = @marketc[counter]
    counter += 1
    @@all << crypto_info
  end
end