module PryState::Printer

def truncate text, length

def truncate text, length
  if text.nil? then return end
  return text unless ENV['TRUNCATE']
  l = length - "...".length
  (text.chars.to_a.size > length ? text.chars.to_a[0...l].join + "..." : text).to_s
end