Class: Hash
Overview
LTSV
Constant Summary collapse
- SingleLength =
50- KeyLengthMax =
30
Instance Method Summary collapse
Instance Method Details
#inspect ⇒ Object
245 246 247 248 249 250 251 252 253 |
# File 'lib/pretty_debug.rb', line 245 def inspect keys = self.keys.map(&:inspect) # When `self == empty?`, `...max` becomes `nil`. `to_i` turns it to `0`. w = keys.map(&:length).max.to_i w = w > KeyLengthMax ? KeyLengthMax : w s = [keys, values].transpose.map{|k, v| "#{k.ljust(w)} => #{v.inspect}"} length < 2 || s.map(&:length).inject(:+) < SingleLength ? "{#{s.join(", ".freeze)}}" : "{#$/#{s.join(",#$/".freeze).indent}#$/}" end |
#ltsv ⇒ Object
288 |
# File 'lib/pretty_debug.rb', line 288 def ltsv; map{|k, v| "#{k}:#{v.to_s.tr("\t".freeze, " ".freeze)}"}.join("\t".freeze) end |