Class: StockQuoteCLI::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/stock_quote_cli/text.rb

Class Method Summary collapse

Class Method Details

.green(str) ⇒ Object



6
# File 'lib/stock_quote_cli/text.rb', line 6

def green(str); color(str, "\e[1m\e[32m"); end

.number_with_commas(n) ⇒ Object



9
10
11
12
13
14
# 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) ⇒ Object



5
# File 'lib/stock_quote_cli/text.rb', line 5

def red(str); color(str, "\e[31m"); end

.yellow(str) ⇒ Object



7
# File 'lib/stock_quote_cli/text.rb', line 7

def yellow(str); color(str, "\e[0;33m"); end