Class: Array
Instance Method Summary collapse
Instance Method Details
#align(sep = " ", ellipsis_limit = nil) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/pretty_debug.rb', line 127 def align sep = " ", ellipsis_limit = nil col_widths = transpose.map{|col| col.map{|cell| cell.to_s.length}.max} map{|row| [row, col_widths].parallel{|col, l| max = ellipsis_limit || l l = l.at_most(max) case col when Numeric then col.to_s.ellipsis(max).rjust(l) else col.to_s.ellipsis(max).ljust(l) end }.join(sep)} end |
#compatible?(other) ⇒ Boolean
30 31 32 33 |
# File 'lib/pretty_debug.rb', line 30 def compatible? other other.case?(Array) and other.length == length end |
#inspect ⇒ Object
123 124 125 126 |
# File 'lib/pretty_debug.rb', line 123 def inspect map(&:inspect) .chain{|s| length < 2 ? "[#{s.join}]" : "[#$/#{s.join(",#$/").indent}#$/]"} end |