Class: Hash
Overview
LTSV
Constant Summary collapse
- KeyLengthMax =
30
Instance Method Summary collapse
Instance Method Details
#inspect ⇒ Object
215 216 217 218 219 220 221 |
# File 'lib/pretty_debug.rb', line 215 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.at_most(KeyLengthMax) [keys, values].transpose.map{|k, v| "#{k.ljust(w)} => #{v.inspect}"} .chain{|s| length < 2 ? "{#{s.join}}" : "{#$/#{s.join(",#$/").indent}#$/}"} end |
#ltsv ⇒ Object
256 |
# File 'lib/pretty_debug.rb', line 256 def ltsv; map{|k, v| "#{k}:#{v.to_s.tr("\t", " ")}"}.join("\t") end |