Module: Colour
- Included in:
- CryptocoinFanboi
- Defined in:
- lib/cryptocoin_fanboi.rb
Overview
# Examples
## Basic usage
c = CryptocoinFanboi.new
puts.to_s limit: 5 # Display the top 5 coins
puts c.this_week # Display the top 5 coins this week
puts c.last_day # Display the top 5 coins in the last 24 hours
puts c.last_hour # Display the top 5 coins in the last hour
## Advance usage
### Display a selection of coins in order of rank
c = CryptocoinFanboi.new watch: %w(btc xrp eth trx dash xmr neo xem)
puts.to_s
### Ignore possibly risky coins (e.g. Asian stock market coins etc.)
c = CryptocoinFanboi.new ignore: %w(xp bts kcs gxs rhoc)
puts c.this_week
Instance Method Summary collapse
- #colourise(x) ⇒ Object (also: #c)
Instance Method Details
#colourise(x) ⇒ Object Also known as: c
63 64 65 66 67 68 69 70 71 |
# File 'lib/cryptocoin_fanboi.rb', line 63 def colourise(x) return x if x.to_s.strip.empty? or @colored == false s3 = (x.to_s.sub(/[\d\.\-]+/) {|s2| "%.2f" % s2.to_f}) s = s3.length == x.to_s.length ? s3 : s3.sub(/ /,'') s[/^ *-/] ? s.red : s.green end |