Class: Coingecko::Coin
- Inherits:
-
Object
- Object
- Coingecko::Coin
- Defined in:
- lib/coingecko/coin.rb
Constant Summary collapse
- @@all =
[]
- @@top_coins =
[]
Instance Attribute Summary collapse
-
#ath ⇒ Object
Returns the value of attribute ath.
-
#ath_change_percentage ⇒ Object
Returns the value of attribute ath_change_percentage.
-
#ath_date ⇒ Object
Returns the value of attribute ath_date.
-
#block_time_in_minutes ⇒ Object
Returns the value of attribute block_time_in_minutes.
-
#blockchain_site ⇒ Object
Returns the value of attribute blockchain_site.
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#circulating_supply ⇒ Object
Returns the value of attribute circulating_supply.
-
#coin ⇒ Object
Returns the value of attribute coin.
-
#coingecko_rank ⇒ Object
Returns the value of attribute coingecko_rank.
-
#coingecko_score ⇒ Object
Returns the value of attribute coingecko_score.
-
#community_data ⇒ Object
Returns the value of attribute community_data.
-
#community_score ⇒ Object
Returns the value of attribute community_score.
-
#contract_address ⇒ Object
Returns the value of attribute contract_address.
-
#country_origin ⇒ Object
Returns the value of attribute country_origin.
-
#current_price ⇒ Object
Returns the value of attribute current_price.
-
#description ⇒ Object
Returns the value of attribute description.
-
#developer_data ⇒ Object
Returns the value of attribute developer_data.
-
#developer_score ⇒ Object
Returns the value of attribute developer_score.
-
#genesis_date ⇒ Object
Returns the value of attribute genesis_date.
-
#high_24h ⇒ Object
Returns the value of attribute high_24h.
-
#homepage ⇒ Object
Returns the value of attribute homepage.
-
#ico_data ⇒ Object
Returns the value of attribute ico_data.
-
#id ⇒ Object
Returns the value of attribute id.
-
#image ⇒ Object
Returns the value of attribute image.
-
#last_updated ⇒ Object
Returns the value of attribute last_updated.
-
#links ⇒ Object
Returns the value of attribute links.
-
#liquidity_score ⇒ Object
Returns the value of attribute liquidity_score.
-
#localization ⇒ Object
Returns the value of attribute localization.
-
#low_24h ⇒ Object
Returns the value of attribute low_24h.
-
#market_cap ⇒ Object
Returns the value of attribute market_cap.
-
#market_cap_change_24h ⇒ Object
Returns the value of attribute market_cap_change_24h.
-
#market_cap_change_percentage_24h ⇒ Object
Returns the value of attribute market_cap_change_percentage_24h.
-
#market_cap_rank ⇒ Object
Returns the value of attribute market_cap_rank.
-
#market_data ⇒ Object
Returns the value of attribute market_data.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price_change_24h ⇒ Object
Returns the value of attribute price_change_24h.
-
#price_change_24h_in_currency ⇒ Object
Returns the value of attribute price_change_24h_in_currency.
-
#price_change_percentage_1y_in_currency ⇒ Object
Returns the value of attribute price_change_percentage_1y_in_currency.
-
#price_change_percentage_24h ⇒ Object
Returns the value of attribute price_change_percentage_24h.
-
#price_change_percentage_30d_in_currency ⇒ Object
Returns the value of attribute price_change_percentage_30d_in_currency.
-
#price_change_percentage_7d_in_currency ⇒ Object
Returns the value of attribute price_change_percentage_7d_in_currency.
-
#public_interest_score ⇒ Object
Returns the value of attribute public_interest_score.
-
#public_interest_stats ⇒ Object
Returns the value of attribute public_interest_stats.
-
#roi ⇒ Object
Returns the value of attribute roi.
-
#sparkline_7d ⇒ Object
Returns the value of attribute sparkline_7d.
-
#status_updates ⇒ Object
Returns the value of attribute status_updates.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
-
#tickers ⇒ Object
Returns the value of attribute tickers.
-
#total_supply ⇒ Object
Returns the value of attribute total_supply.
-
#total_volume ⇒ Object
Returns the value of attribute total_volume.
Class Method Summary collapse
- .all ⇒ Object
- .get_coin(coin_id) ⇒ Object
- .new_from_top_100(currency = "usd") ⇒ Object
- .reset(collection) ⇒ Object
- .top_coins ⇒ Object
Instance Method Summary collapse
-
#initialize(id = nil, symbol = nil, name = nil, market_cap_rank = nil, last_updated = nil) ⇒ Coin
constructor
A new instance of Coin.
- #save ⇒ Object
Constructor Details
#initialize(id = nil, symbol = nil, name = nil, market_cap_rank = nil, last_updated = nil) ⇒ Coin
Returns a new instance of Coin.
7 8 9 10 11 12 13 14 |
# 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 |
Instance Attribute Details
#ath ⇒ Object
Returns the value of attribute ath.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def ath @ath end |
#ath_change_percentage ⇒ Object
Returns the value of attribute ath_change_percentage.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def ath_change_percentage @ath_change_percentage end |
#ath_date ⇒ Object
Returns the value of attribute ath_date.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def ath_date @ath_date end |
#block_time_in_minutes ⇒ Object
Returns the value of attribute block_time_in_minutes.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def block_time_in_minutes @block_time_in_minutes end |
#blockchain_site ⇒ Object
Returns the value of attribute blockchain_site.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def blockchain_site @blockchain_site end |
#categories ⇒ Object
Returns the value of attribute categories.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def categories @categories end |
#circulating_supply ⇒ Object
Returns the value of attribute circulating_supply.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def circulating_supply @circulating_supply end |
#coin ⇒ Object
Returns the value of attribute coin.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def coin @coin end |
#coingecko_rank ⇒ Object
Returns the value of attribute coingecko_rank.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def coingecko_rank @coingecko_rank end |
#coingecko_score ⇒ Object
Returns the value of attribute coingecko_score.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def coingecko_score @coingecko_score end |
#community_data ⇒ Object
Returns the value of attribute community_data.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def community_data @community_data end |
#community_score ⇒ Object
Returns the value of attribute community_score.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def community_score @community_score end |
#contract_address ⇒ Object
Returns the value of attribute contract_address.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def contract_address @contract_address end |
#country_origin ⇒ Object
Returns the value of attribute country_origin.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def country_origin @country_origin end |
#current_price ⇒ Object
Returns the value of attribute current_price.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def current_price @current_price end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def description @description end |
#developer_data ⇒ Object
Returns the value of attribute developer_data.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def developer_data @developer_data end |
#developer_score ⇒ Object
Returns the value of attribute developer_score.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def developer_score @developer_score end |
#genesis_date ⇒ Object
Returns the value of attribute genesis_date.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def genesis_date @genesis_date end |
#high_24h ⇒ Object
Returns the value of attribute high_24h.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def high_24h @high_24h end |
#homepage ⇒ Object
Returns the value of attribute homepage.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def homepage @homepage end |
#ico_data ⇒ Object
Returns the value of attribute ico_data.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def ico_data @ico_data end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def id @id end |
#image ⇒ Object
Returns the value of attribute image.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def image @image end |
#last_updated ⇒ Object
Returns the value of attribute last_updated.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def last_updated @last_updated end |
#links ⇒ Object
Returns the value of attribute links.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def links @links end |
#liquidity_score ⇒ Object
Returns the value of attribute liquidity_score.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def liquidity_score @liquidity_score end |
#localization ⇒ Object
Returns the value of attribute localization.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def localization @localization end |
#low_24h ⇒ Object
Returns the value of attribute low_24h.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def low_24h @low_24h end |
#market_cap ⇒ Object
Returns the value of attribute market_cap.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def market_cap @market_cap end |
#market_cap_change_24h ⇒ Object
Returns the value of attribute market_cap_change_24h.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def market_cap_change_24h @market_cap_change_24h end |
#market_cap_change_percentage_24h ⇒ Object
Returns the value of attribute market_cap_change_percentage_24h.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def market_cap_change_percentage_24h @market_cap_change_percentage_24h end |
#market_cap_rank ⇒ Object
Returns the value of attribute market_cap_rank.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def market_cap_rank @market_cap_rank end |
#market_data ⇒ Object
Returns the value of attribute market_data.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def market_data @market_data end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def name @name end |
#price_change_24h ⇒ Object
Returns the value of attribute price_change_24h.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def price_change_24h @price_change_24h end |
#price_change_24h_in_currency ⇒ Object
Returns the value of attribute price_change_24h_in_currency.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def price_change_24h_in_currency @price_change_24h_in_currency end |
#price_change_percentage_1y_in_currency ⇒ Object
Returns the value of attribute price_change_percentage_1y_in_currency.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def price_change_percentage_1y_in_currency @price_change_percentage_1y_in_currency end |
#price_change_percentage_24h ⇒ Object
Returns the value of attribute price_change_percentage_24h.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def price_change_percentage_24h @price_change_percentage_24h end |
#price_change_percentage_30d_in_currency ⇒ Object
Returns the value of attribute price_change_percentage_30d_in_currency.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def price_change_percentage_30d_in_currency @price_change_percentage_30d_in_currency end |
#price_change_percentage_7d_in_currency ⇒ Object
Returns the value of attribute price_change_percentage_7d_in_currency.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def price_change_percentage_7d_in_currency @price_change_percentage_7d_in_currency end |
#public_interest_score ⇒ Object
Returns the value of attribute public_interest_score.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def public_interest_score @public_interest_score end |
#public_interest_stats ⇒ Object
Returns the value of attribute public_interest_stats.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def public_interest_stats @public_interest_stats end |
#roi ⇒ Object
Returns the value of attribute roi.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def roi @roi end |
#sparkline_7d ⇒ Object
Returns the value of attribute sparkline_7d.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def sparkline_7d @sparkline_7d end |
#status_updates ⇒ Object
Returns the value of attribute status_updates.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def status_updates @status_updates end |
#symbol ⇒ Object
Returns the value of attribute symbol.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def symbol @symbol end |
#tickers ⇒ Object
Returns the value of attribute tickers.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def tickers @tickers end |
#total_supply ⇒ Object
Returns the value of attribute total_supply.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def total_supply @total_supply end |
#total_volume ⇒ Object
Returns the value of attribute total_volume.
2 3 4 |
# File 'lib/coingecko/coin.rb', line 2 def total_volume @total_volume end |
Class Method Details
.all ⇒ Object
16 17 18 |
# File 'lib/coingecko/coin.rb', line 16 def self.all @@all end |
.get_coin(coin_id) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# 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_from_top_100(currency = "usd") ⇒ Object
33 34 35 36 37 38 39 |
# 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) ⇒ Object
28 29 30 |
# File 'lib/coingecko/coin.rb', line 28 def self.reset(collection) collection.clear end |
.top_coins ⇒ Object
20 21 22 |
# File 'lib/coingecko/coin.rb', line 20 def self.top_coins @@top_coins end |
Instance Method Details
#save ⇒ Object
24 25 26 |
# File 'lib/coingecko/coin.rb', line 24 def save @@all << self end |