unhappychoice/bitflyer-cli

View on GitHub
lib/bitflyer/cli/ext/string.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'colorize'

class String
  def color_with_number(number)
    sign = number >= 0.0 ? '+' : ''
    sign + colorize(number >= 0.0 ? :green : :red)
  end

  def split_by_comma
    reverse.gsub( /(\d{3})(?=\d)/, '\1,').reverse
  end
end