module Colour

# 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

end

Public Instance Methods

c(x)
Alias for: colourise
colourise(x) click to toggle source
# 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
Also aliased as: c