class Coingecko::Coin

Attributes

ath[RW]
ath_change_percentage[RW]
ath_date[RW]
block_time_in_minutes[RW]
blockchain_site[RW]
categories[RW]
circulating_supply[RW]
coin[RW]
coingecko_rank[RW]
coingecko_score[RW]
community_data[RW]
community_score[RW]
contract_address[RW]
country_origin[RW]
current_price[RW]
description[RW]
developer_data[RW]
developer_score[RW]
genesis_date[RW]
high_24h[RW]
homepage[RW]
ico_data[RW]
id[RW]
image[RW]
last_updated[RW]
liquidity_score[RW]
localization[RW]
low_24h[RW]
market_cap[RW]
market_cap_change_24h[RW]
market_cap_change_percentage_24h[RW]
market_cap_rank[RW]
market_data[RW]
name[RW]
price_change_24h[RW]
price_change_24h_in_currency[RW]
price_change_percentage_1y_in_currency[RW]
price_change_percentage_24h[RW]
price_change_percentage_30d_in_currency[RW]
price_change_percentage_7d_in_currency[RW]
public_interest_score[RW]
public_interest_stats[RW]
roi[RW]
sparkline_7d[RW]
status_updates[RW]
symbol[RW]
tickers[RW]
total_supply[RW]
total_volume[RW]

Public Class Methods

all() click to toggle source
# File lib/coingecko/coin.rb, line 16
def self.all
  @@all
end
get_coin(coin_id) click to toggle source
# File lib/coingecko/coin.rb, line 41
def self.get_coin(coin_id)
  Coingecko::Coin.new.tap do |coin| 
   Coingecko::API.look_up_coin(coin_id).each do |k,v|
        coin.send("#{k}=", v)
     end 
     @@all << coin
   end 
 #binding.pry
end
new(id=nil, symbol=nil, name=nil, market_cap_rank=nil, last_updated=nil) click to toggle source
# File lib/coingecko/coin.rb, line 7
def initialize(id=nil, symbol=nil, name=nil, market_cap_rank=nil, last_updated=nil)
  @id = id 
  @symbol = symbol
  @name = name
  @market_cap_rank = market_cap_rank
  @last_updated = last_updated
  #@@all << self
end
new_from_top_100(currency="usd") click to toggle source
# File lib/coingecko/coin.rb, line 33
def self.new_from_top_100(currency="usd")
 reset(@@top_coins)
 json = Coingecko::API.list_top_100(currency) 
   json.each do |coin| 
     @@top_coins << self.new(coin["id"], coin["symbol"], coin["name"], coin["market_cap_rank"], coin["last_updated"])
      end 
end
reset(collection) click to toggle source
# File lib/coingecko/coin.rb, line 28
def self.reset(collection)
  collection.clear
end
top_coins() click to toggle source
# File lib/coingecko/coin.rb, line 20
def self.top_coins
  @@top_coins
end

Public Instance Methods

save() click to toggle source
# File lib/coingecko/coin.rb, line 24
def save
  @@all << self 
end