Class: Capwatch::Coin
- Inherits:
-
Object
- Object
- Capwatch::Coin
- Defined in:
- lib/capwatch/coin.rb
Instance Attribute Summary collapse
-
#distribution ⇒ Object
Returns the value of attribute distribution.
-
#name ⇒ Object
Returns the value of attribute name.
-
#percent_change_1h ⇒ Object
Returns the value of attribute percent_change_1h.
-
#percent_change_24h ⇒ Object
Returns the value of attribute percent_change_24h.
-
#percent_change_7d ⇒ Object
Returns the value of attribute percent_change_7d.
-
#price_btc ⇒ Object
Returns the value of attribute price_btc.
-
#price_usd ⇒ Object
Returns the value of attribute price_usd.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Coin
constructor
A new instance of Coin.
- #price_eth ⇒ Object
- #serialize ⇒ Object
- #value_btc ⇒ Object
- #value_eth ⇒ Object
- #value_usd ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Coin
Returns a new instance of Coin.
12 13 14 |
# File 'lib/capwatch/coin.rb', line 12 def initialize yield self if block_given? end |
Instance Attribute Details
#distribution ⇒ Object
Returns the value of attribute distribution.
5 6 7 |
# File 'lib/capwatch/coin.rb', line 5 def distribution @distribution end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/capwatch/coin.rb', line 5 def name @name end |
#percent_change_1h ⇒ Object
Returns the value of attribute percent_change_1h.
5 6 7 |
# File 'lib/capwatch/coin.rb', line 5 def percent_change_1h @percent_change_1h end |
#percent_change_24h ⇒ Object
Returns the value of attribute percent_change_24h.
5 6 7 |
# File 'lib/capwatch/coin.rb', line 5 def percent_change_24h @percent_change_24h end |
#percent_change_7d ⇒ Object
Returns the value of attribute percent_change_7d.
5 6 7 |
# File 'lib/capwatch/coin.rb', line 5 def percent_change_7d @percent_change_7d end |
#price_btc ⇒ Object
Returns the value of attribute price_btc.
5 6 7 |
# File 'lib/capwatch/coin.rb', line 5 def price_btc @price_btc end |
#price_usd ⇒ Object
Returns the value of attribute price_usd.
5 6 7 |
# File 'lib/capwatch/coin.rb', line 5 def price_usd @price_usd end |
#quantity ⇒ Object
Returns the value of attribute quantity.
5 6 7 |
# File 'lib/capwatch/coin.rb', line 5 def quantity @quantity end |
#symbol ⇒ Object
Returns the value of attribute symbol.
5 6 7 |
# File 'lib/capwatch/coin.rb', line 5 def symbol @symbol end |
Instance Method Details
#price_eth ⇒ Object
28 29 30 |
# File 'lib/capwatch/coin.rb', line 28 def price_eth price_btc / Exchange.rate_for("ETH") end |
#serialize ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/capwatch/coin.rb', line 32 def serialize { symbol: symbol, name: name, quantity: quantity, price_usd: price_usd, price_btc: price_btc, distribution: distribution, percent_change_1h: percent_change_1h, percent_change_24h: percent_change_24h, percent_change_7d: percent_change_7d, value_btc: value_btc, value_usd: value_usd, value_eth: value_eth, price_eth: price_eth, } end |
#value_btc ⇒ Object
16 17 18 |
# File 'lib/capwatch/coin.rb', line 16 def value_btc price_btc * quantity end |
#value_eth ⇒ Object
24 25 26 |
# File 'lib/capwatch/coin.rb', line 24 def value_eth price_eth * quantity end |
#value_usd ⇒ Object
20 21 22 |
# File 'lib/capwatch/coin.rb', line 20 def value_usd price_usd * quantity end |