Class: Satoshi::Coin
- Inherits:
-
Object
- Object
- Satoshi::Coin
- Defined in:
- lib/satoshi/coin.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#btc_market_cap ⇒ Object
Returns the value of attribute btc_market_cap.
-
#btc_price ⇒ Object
Returns the value of attribute btc_price.
-
#circulating_supply_btc ⇒ Object
Returns the value of attribute circulating_supply_btc.
-
#index ⇒ Object
Returns the value of attribute index.
-
#info_link ⇒ Object
Returns the value of attribute info_link.
-
#last_price ⇒ Object
Returns the value of attribute last_price.
-
#max_supply ⇒ Object
Returns the value of attribute max_supply.
-
#name ⇒ Object
Returns the value of attribute name.
-
#percent_change ⇒ Object
Returns the value of attribute percent_change.
-
#ticker ⇒ Object
Returns the value of attribute ticker.
-
#usd_market_cap ⇒ Object
Returns the value of attribute usd_market_cap.
-
#usd_price ⇒ Object
Returns the value of attribute usd_price.
-
#volume_btc_24hr ⇒ Object
Returns the value of attribute volume_btc_24hr.
-
#volume_usd_24hr ⇒ Object
Returns the value of attribute volume_usd_24hr.
Class Method Summary collapse
- .all ⇒ Object
- .create(name, link, index, price) ⇒ Object
- .find_by_name(name) ⇒ Object
- .sort_all_by_index ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#btc_market_cap ⇒ Object
Returns the value of attribute btc_market_cap.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def btc_market_cap @btc_market_cap end |
#btc_price ⇒ Object
Returns the value of attribute btc_price.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def btc_price @btc_price end |
#circulating_supply_btc ⇒ Object
Returns the value of attribute circulating_supply_btc.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def circulating_supply_btc @circulating_supply_btc end |
#index ⇒ Object
Returns the value of attribute index.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def index @index end |
#info_link ⇒ Object
Returns the value of attribute info_link.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def info_link @info_link end |
#last_price ⇒ Object
Returns the value of attribute last_price.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def last_price @last_price end |
#max_supply ⇒ Object
Returns the value of attribute max_supply.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def max_supply @max_supply end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def name @name end |
#percent_change ⇒ Object
Returns the value of attribute percent_change.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def percent_change @percent_change end |
#ticker ⇒ Object
Returns the value of attribute ticker.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def ticker @ticker end |
#usd_market_cap ⇒ Object
Returns the value of attribute usd_market_cap.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def usd_market_cap @usd_market_cap end |
#usd_price ⇒ Object
Returns the value of attribute usd_price.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def usd_price @usd_price end |
#volume_btc_24hr ⇒ Object
Returns the value of attribute volume_btc_24hr.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def volume_btc_24hr @volume_btc_24hr end |
#volume_usd_24hr ⇒ Object
Returns the value of attribute volume_usd_24hr.
2 3 4 |
# File 'lib/satoshi/coin.rb', line 2 def volume_usd_24hr @volume_usd_24hr end |
Class Method Details
.all ⇒ Object
24 25 26 |
# File 'lib/satoshi/coin.rb', line 24 def self.all @@all end |
.create(name, link, index, price) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/satoshi/coin.rb', line 9 def self.create(name, link, index, price) coin = self.new coin.name = name coin.info_link = link coin.index = index coin.usd_price = price coin.last_price = price.to_f coin.save self.sort_all_by_index end |
.find_by_name(name) ⇒ Object
48 49 50 |
# File 'lib/satoshi/coin.rb', line 48 def self.find_by_name(name) self.all.find {|coin| coin.name.downcase == name.downcase} end |
.sort_all_by_index ⇒ Object
20 21 22 |
# File 'lib/satoshi/coin.rb', line 20 def self.sort_all_by_index self.all.sort_by { |coin| coin.index} end |
Instance Method Details
#display_info ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/satoshi/coin.rb', line 35 def display_info puts "-------------------------" puts "#{self.name} = $#{self.usd_price}" puts "Price In btc = #{self.btc_price}" puts "Ticker = #{self.ticker}" puts "24hr Percent Change = #{self.percent_change}%" puts "Market Cap = $#{self.usd_market_cap} = #{self.btc_market_cap} btc" puts "24hr Volume = $#{self.volume_usd_24hr} = #{self.volume_btc_24hr} btc" puts "Circulating Supply = #{self.circulating_supply_btc}" puts "Max Supply = #{self.max_supply}" if self.max_supply puts "-------------------------" end |
#load_info(info_hash) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/satoshi/coin.rb', line 28 def load_info(info_hash) info_hash.each {|key, value| self.send("#{key}=",value) } display_info end |
#save ⇒ Object
5 6 7 |
# File 'lib/satoshi/coin.rb', line 5 def save self.class.all << self end |