class Tailstrom::Table

Public Class Methods

new(schema) click to toggle source
# File lib/tailstrom/table.rb, line 3
def initialize(schema)
  @schema = schema
  @out = $stdout
end

Public Instance Methods

print_header() click to toggle source
print_row(*cols) click to toggle source
puts(*args) click to toggle source
# File lib/tailstrom/table.rb, line 33
def puts(*args)
  @out.puts *args
end

Private Instance Methods

format_string(value) click to toggle source
# File lib/tailstrom/table.rb, line 38
def format_string(value)
  case value
  when Numeric
    num_with_delim value
  when nil
    '-'
  else
    value
  end
end
num_with_delim(num) click to toggle source
# File lib/tailstrom/table.rb, line 49
def num_with_delim(num)
  head, tail = num.to_s.split('.')
  head.gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
  if tail
    "#{head}.#{tail[0..2]}"
  else
    head
  end
end