Method: Matrix#pretty_inspect
- Defined in:
- lib/y_support/stdlib_ext/matrix/misc.rb
#pretty_inspect ⇒ Object
Pretty inspect
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/y_support/stdlib_ext/matrix/misc.rb', line 7 def pretty_inspect return inspect if row_size == 0 or column_size == 0 aa = send(:rows).each.with_object [] do |row, memo| memo << row.map{ |o| os = o.to_s case o when Numeric then os[0] == '-' ? os : ' ' + os else o.to_s end } end width = aa.map{ |row| row.map( &:size ).max }.max + 1 aa.each_with_object "" do |row, memo| row.each{ |e| memo << e << ' ' * ( width - e.size ) } memo << "\n" end end |