class Cryptonewbie::Crypto
Attributes
change[RW]
circulating_supply[RW]
name[RW]
price[RW]
url[RW]
website[RW]
Public Class Methods
all()
click to toggle source
# File lib/cryptonewbie/crypto.rb, line 19 def self.all @@all end
find(input)
click to toggle source
# File lib/cryptonewbie/crypto.rb, line 29 def self.find(input) self.all[input - 1] end
find_by_name(name)
click to toggle source
# File lib/cryptonewbie/crypto.rb, line 23 def self.find_by_name(name) self.all.detect do |crypto| crypto.name.downcase.strip == name.downcase.strip end end
new(name = nil, url = nil)
click to toggle source
# File lib/cryptonewbie/crypto.rb, line 13 def initialize(name = nil, url = nil) @name = name @url = url @@all << self end
new_from_index_page(coin)
click to toggle source
# File lib/cryptonewbie/crypto.rb, line 6 def self.new_from_index_page(coin) self.new( coin.css('a.currency-name-container').text, "https://coinmarketcap.com#{coin.css("a").attribute("href").text}" ) end
Public Instance Methods
doc()
click to toggle source
# File lib/cryptonewbie/crypto.rb, line 33 def doc @doc ||= Nokogiri::HTML(open(self.url)) end