Class: CryptoStats
- Inherits:
-
Object
- Object
- CryptoStats
- Defined in:
- lib/models/cryptostats.rb
Constant Summary collapse
- @@all =
[]
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.
-
#atl ⇒ Object
Returns the value of attribute atl.
-
#atl_change_percentage ⇒ Object
Returns the value of attribute atl_change_percentage.
-
#atl_date ⇒ Object
Returns the value of attribute atl_date.
-
#circulating_supply ⇒ Object
Returns the value of attribute circulating_supply.
-
#current_price ⇒ Object
Returns the value of attribute current_price.
-
#fully_diluted_valuation ⇒ Object
Returns the value of attribute fully_diluted_valuation.
-
#high_24h ⇒ Object
Returns the value of attribute high_24h.
-
#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.
-
#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.
-
#max_supply ⇒ Object
Returns the value of attribute max_supply.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price_change_24h ⇒ Object
Returns the value of attribute price_change_24h.
-
#price_change_percentage_24h ⇒ Object
Returns the value of attribute price_change_percentage_24h.
-
#roi ⇒ Object
Returns the value of attribute roi.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
-
#total_supply ⇒ Object
Returns the value of attribute total_supply.
-
#total_volume ⇒ Object
Returns the value of attribute total_volume.
Class Method Summary collapse
Instance Method Summary collapse
- #display_stats ⇒ Object
-
#initialize(attributes) ⇒ CryptoStats
constructor
A new instance of CryptoStats.
Constructor Details
#initialize(attributes) ⇒ CryptoStats
Returns a new instance of CryptoStats.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/models/cryptostats.rb', line 8 def initialize(attributes) # attributes.each do |key, value| # self.class.attr_accessor(key) # self.send(("#{key}="), value) # @@all << self # end attributes.each {|key, value| self.send(("#{key}="), value)} @@all << self end |
Instance Attribute Details
#ath ⇒ Object
Returns the value of attribute ath.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def ath @ath end |
#ath_change_percentage ⇒ Object
Returns the value of attribute ath_change_percentage.
2 3 4 |
# File 'lib/models/cryptostats.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/models/cryptostats.rb', line 2 def ath_date @ath_date end |
#atl ⇒ Object
Returns the value of attribute atl.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def atl @atl end |
#atl_change_percentage ⇒ Object
Returns the value of attribute atl_change_percentage.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def atl_change_percentage @atl_change_percentage end |
#atl_date ⇒ Object
Returns the value of attribute atl_date.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def atl_date @atl_date end |
#circulating_supply ⇒ Object
Returns the value of attribute circulating_supply.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def circulating_supply @circulating_supply end |
#current_price ⇒ Object
Returns the value of attribute current_price.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def current_price @current_price end |
#fully_diluted_valuation ⇒ Object
Returns the value of attribute fully_diluted_valuation.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def fully_diluted_valuation @fully_diluted_valuation end |
#high_24h ⇒ Object
Returns the value of attribute high_24h.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def high_24h @high_24h end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def id @id end |
#image ⇒ Object
Returns the value of attribute image.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def image @image end |
#last_updated ⇒ Object
Returns the value of attribute last_updated.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def last_updated @last_updated end |
#low_24h ⇒ Object
Returns the value of attribute low_24h.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def low_24h @low_24h end |
#market_cap ⇒ Object
Returns the value of attribute market_cap.
2 3 4 |
# File 'lib/models/cryptostats.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/models/cryptostats.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/models/cryptostats.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/models/cryptostats.rb', line 2 def market_cap_rank @market_cap_rank end |
#max_supply ⇒ Object
Returns the value of attribute max_supply.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def max_supply @max_supply end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def name @name end |
#price_change_24h ⇒ Object
Returns the value of attribute price_change_24h.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def price_change_24h @price_change_24h end |
#price_change_percentage_24h ⇒ Object
Returns the value of attribute price_change_percentage_24h.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def price_change_percentage_24h @price_change_percentage_24h end |
#roi ⇒ Object
Returns the value of attribute roi.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def roi @roi end |
#symbol ⇒ Object
Returns the value of attribute symbol.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def symbol @symbol end |
#total_supply ⇒ Object
Returns the value of attribute total_supply.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def total_supply @total_supply end |
#total_volume ⇒ Object
Returns the value of attribute total_volume.
2 3 4 |
# File 'lib/models/cryptostats.rb', line 2 def total_volume @total_volume end |
Class Method Details
.all ⇒ Object
19 20 21 |
# File 'lib/models/cryptostats.rb', line 19 def self.all @@all end |
Instance Method Details
#display_stats ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/models/cryptostats.rb', line 23 def display_stats puts "-------------------------------------------- Crypto Stats --------------------------------------------" #crypto_logo(self.image) puts "Name: #{self.name}" puts "Symbol: #{self.symbol.upcase}" puts "Current Price: $#{self.current_price}" puts "Market Cap: $#{self.market_cap}" puts "Total Volume: $#{self.total_volume}" puts "High (24hrs): $#{self.high_24h}" puts "Low (24hrs): $#{self.low_24h}" puts "Price Change (24hrs): $#{self.price_change_24h}" puts "Percentage Change (24hrs): #{self.price_change_percentage_24h}%" puts "Last Updated: #{self.last_updated}" puts "------------------------------------------------------------------------------------------------------" end |