Class: CryptoStats

Inherits:
Object
  • Object
show all
Defined in:
lib/models/cryptostats.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#athObject

Returns the value of attribute ath.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def ath
  @ath
end

#ath_change_percentageObject

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_dateObject

Returns the value of attribute ath_date.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def ath_date
  @ath_date
end

#atlObject

Returns the value of attribute atl.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def atl
  @atl
end

#atl_change_percentageObject

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_dateObject

Returns the value of attribute atl_date.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def atl_date
  @atl_date
end

#circulating_supplyObject

Returns the value of attribute circulating_supply.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def circulating_supply
  @circulating_supply
end

#current_priceObject

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_valuationObject

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_24hObject

Returns the value of attribute high_24h.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def high_24h
  @high_24h
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def id
  @id
end

#imageObject

Returns the value of attribute image.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def image
  @image
end

#last_updatedObject

Returns the value of attribute last_updated.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def last_updated
  @last_updated
end

#low_24hObject

Returns the value of attribute low_24h.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def low_24h
  @low_24h
end

#market_capObject

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_24hObject

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_24hObject

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_rankObject

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_supplyObject

Returns the value of attribute max_supply.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def max_supply
  @max_supply
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def name
  @name
end

#price_change_24hObject

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_24hObject

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

#roiObject

Returns the value of attribute roi.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def roi
  @roi
end

#symbolObject

Returns the value of attribute symbol.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def symbol
  @symbol
end

#total_supplyObject

Returns the value of attribute total_supply.



2
3
4
# File 'lib/models/cryptostats.rb', line 2

def total_supply
  @total_supply
end

#total_volumeObject

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

.allObject



19
20
21
# File 'lib/models/cryptostats.rb', line 19

def self.all
    @@all
end

Instance Method Details

#display_statsObject



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