Method: CSV::Table#inspect

Defined in:
lib/csv/table.rb

#inspectObject

:call-seq:

table.inspect => string

Returns a US-ASCII-encoded String showing table:

  • Class: CSV::Table.

  • Access mode: :row, :col, or :col_or_row.

  • Size: Row count, including the header row.

Example:

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
table.inspect # => "#<CSV::Table mode:col_or_row row_count:4>\nName,Value\nfoo,0\nbar,1\nbaz,2\n"


1048
1049
1050
1051
1052
1053
# File 'lib/csv/table.rb', line 1048

def inspect
  inspected = +"#<#{self.class} mode:#{@mode} row_count:#{to_a.size}>"
  summary = to_csv(limit: 5)
  inspected << "\n" << summary if summary.encoding.ascii_compatible?
  inspected
end