Class: Coingecko::Coin

Inherits:
Object
  • Object
show all
Defined in:
lib/coingecko/coin.rb

Constant Summary collapse

@@all =
[]
@@top_coins =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#athObject

Returns the value of attribute ath.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def ath
  @ath
end

#ath_change_percentageObject

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_dateObject

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_minutesObject

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_siteObject

Returns the value of attribute blockchain_site.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def blockchain_site
  @blockchain_site
end

#categoriesObject

Returns the value of attribute categories.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def categories
  @categories
end

#circulating_supplyObject

Returns the value of attribute circulating_supply.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def circulating_supply
  @circulating_supply
end

#coinObject

Returns the value of attribute coin.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def coin
  @coin
end

#coingecko_rankObject

Returns the value of attribute coingecko_rank.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def coingecko_rank
  @coingecko_rank
end

#coingecko_scoreObject

Returns the value of attribute coingecko_score.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def coingecko_score
  @coingecko_score
end

#community_dataObject

Returns the value of attribute community_data.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def community_data
  @community_data
end

#community_scoreObject

Returns the value of attribute community_score.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def community_score
  @community_score
end

#contract_addressObject

Returns the value of attribute contract_address.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def contract_address
  @contract_address
end

#country_originObject

Returns the value of attribute country_origin.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def country_origin
  @country_origin
end

#current_priceObject

Returns the value of attribute current_price.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def current_price
  @current_price
end

#descriptionObject

Returns the value of attribute description.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def description
  @description
end

#developer_dataObject

Returns the value of attribute developer_data.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def developer_data
  @developer_data
end

#developer_scoreObject

Returns the value of attribute developer_score.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def developer_score
  @developer_score
end

#genesis_dateObject

Returns the value of attribute genesis_date.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def genesis_date
  @genesis_date
end

#high_24hObject

Returns the value of attribute high_24h.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def high_24h
  @high_24h
end

#homepageObject

Returns the value of attribute homepage.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def homepage
  @homepage
end

#ico_dataObject

Returns the value of attribute ico_data.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def ico_data
  @ico_data
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def id
  @id
end

#imageObject

Returns the value of attribute image.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def image
  @image
end

#last_updatedObject

Returns the value of attribute last_updated.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def last_updated
  @last_updated
end

Returns the value of attribute links.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def links
  @links
end

#liquidity_scoreObject

Returns the value of attribute liquidity_score.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def liquidity_score
  @liquidity_score
end

#localizationObject

Returns the value of attribute localization.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def localization
  @localization
end

#low_24hObject

Returns the value of attribute low_24h.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def low_24h
  @low_24h
end

#market_capObject

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_24hObject

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_24hObject

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_rankObject

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_dataObject

Returns the value of attribute market_data.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def market_data
  @market_data
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def name
  @name
end

#price_change_24hObject

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_currencyObject

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_currencyObject

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_24hObject

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_currencyObject

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_currencyObject

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_scoreObject

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_statsObject

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

#roiObject

Returns the value of attribute roi.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def roi
  @roi
end

#sparkline_7dObject

Returns the value of attribute sparkline_7d.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def sparkline_7d
  @sparkline_7d
end

#status_updatesObject

Returns the value of attribute status_updates.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def status_updates
  @status_updates
end

#symbolObject

Returns the value of attribute symbol.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def symbol
  @symbol
end

#tickersObject

Returns the value of attribute tickers.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def tickers
  @tickers
end

#total_supplyObject

Returns the value of attribute total_supply.



2
3
4
# File 'lib/coingecko/coin.rb', line 2

def total_supply
  @total_supply
end

#total_volumeObject

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

.allObject



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_coinsObject



20
21
22
# File 'lib/coingecko/coin.rb', line 20

def self.top_coins
  @@top_coins
end

Instance Method Details

#saveObject



24
25
26
# File 'lib/coingecko/coin.rb', line 24

def save
  @@all << self 
end