class StockQuoteCLI::Text

Public Class Methods

green(str) click to toggle source
# File lib/stock_quote_cli/text.rb, line 6
def green(str); color(str, "\e[1m\e[32m"); end
number_with_commas(n) click to toggle source
# File lib/stock_quote_cli/text.rb, line 9
def number_with_commas(n)
  int, dec = n.to_s.split(".")
  int.chars.reverse.each_slice(3).reduce("") { |m, s|
    m + s.join + (s.size == 3 ? "," : "")
  }.reverse.gsub(/^,/, '') + (dec ? ".#{dec}" : "")
end
red(str) click to toggle source

color methods from github.com/pierot/stockery/blob/master/lib/stockery.rb

# File lib/stock_quote_cli/text.rb, line 5
def red(str); color(str, "\e[31m"); end
yellow(str) click to toggle source
# File lib/stock_quote_cli/text.rb, line 7
def yellow(str); color(str, "\e[0;33m"); end

Private Class Methods

color(text, color_code) click to toggle source
# File lib/stock_quote_cli/text.rb, line 18
def color(text, color_code)
  "#{color_code}#{text}\e[0m"
end