Class: Cryptonewbie::Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptonewbie/scraper.rb

Instance Method Summary collapse

Instance Method Details

#get_cryptosObject



7
8
9
10
11
# File 'lib/cryptonewbie/scraper.rb', line 7

def get_cryptos
  table = self.get_page.at('table#currencies')
  content = table.css('tbody')
  rows = content.css('tr')
end

#get_pageObject



3
4
5
# File 'lib/cryptonewbie/scraper.rb', line 3

def get_page
  Nokogiri::HTML(open("https://coinmarketcap.com"))
end

#make_cryptosObject



13
14
15
16
17
18
19
# File 'lib/cryptonewbie/scraper.rb', line 13

def make_cryptos
  self.get_cryptos.collect do |coin|
    if coin.css('td.text-center').text.strip.to_i < 6
      Cryptonewbie::Crypto.new_from_index_page(coin)
    end
  end.compact
end