Class: Hash
Constant Summary collapse
- SingleLength =
50- KeyLengthMax =
30
Instance Method Summary collapse
Instance Method Details
#inspect ⇒ Object
205 206 207 208 209 210 211 212 213 |
# File 'lib/pretty_debug.rb', line 205 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 |