📁 File Manager Pro
v10.0.3 | PHP: 8.1.34
Server: Apache
2026-06-22 14:17:31
📂
/ (Root)
/
opt
/
alt
/
ruby31
/
share
/
ri
/
system
/
CSV
/
Table
📍 /opt/alt/ruby31/share/ri/system/CSV/Table
🔄 Refresh
✏️
Editing: cdesc-Table.ri
Read Only
U:RDoc::NormalClass[iI" Table:ETI"CSV::Table;TI"Object;To:RDoc::Markup::Document:@parts[o;;[@S:RDoc::Markup::Heading: leveli: textI"\CSV::Table;To:RDoc::Markup::Paragraph;[I"2A \CSV::Table instance represents \CSV data. ;TI"$(see {class CSV}[../CSV.html]).;To:RDoc::Markup::BlankLine o;;[I"The instance may have:;To:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o;;[I"'Rows: each is a Table::Row object.;To;;0;[o;;[I"$Headers: names for the columns.;T@S; ; i;I"Instance Methods;T@o;;[I"6\CSV::Table has three groups of instance methods:;To;;;;[o;;0;[o;;[I"1Its own internally defined instance methods.;To;;0;[o;;[I"+Methods included by module Enumerable.;To;;0;[o;;[I"'Methods delegated to class Array.:;To;;;;[o;;0;[o;;[I"Array#empty?;To;;0;[o;;[I"Array#length;To;;0;[o;;[I"Array#size;T@S; ; i;I"$Creating a \CSV::Table Instance;T@o;;[I"LCommonly, a new \CSV::Table instance is created by parsing \CSV source ;TI"using headers:;To:RDoc::Markup::Verbatim;[I"2source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" ;TI".table = CSV.parse(source, headers: true) ;TI"!table.class # => CSV::Table ;T:@format0o;;[I"9You can also create an instance directly. See ::new.;T@S; ; i;I"Headers;T@o;;[I"RIf a table has headers, the headers serve as labels for the columns of data. ;TI"4Each header serves as the label for its column.;T@o;;[I"MThe headers for a \CSV::Table object are stored as an \Array of Strings.;T@o;;[I"CCommonly, headers are defined in the first row of \CSV source:;To;;[I"2source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" ;TI".table = CSV.parse(source, headers: true) ;TI"*table.headers # => ["Name", "Value"] ;T;0o;;[I"4If no headers are defined, the \Array is empty:;To;;[I" table = CSV::Table.new([]) ;TI"table.headers # => [] ;T;0S; ; i;I"Access Modes;T@o;;[I"?\CSV::Table provides three modes for accessing table data:;To;;;;[o;;0;[o;;[I"\Row mode.;To;;0;[o;;[I"Column mode.;To;;0;[o;;[I".Mixed mode (the default for a new table).;T@o;;[I"DThe access mode for a\CSV::Table instance affects the behavior ;TI"%of some of its instance methods:;To;;;;[o;;0;[o;;[I"#[];To;;0;[o;;[I" #[]=;To;;0;[o;;[I"#delete;To;;0;[o;;[I"#delete_if;To;;0;[o;;[I" #each;To;;0;[o;;[I"#values_at;T@S; ; i;I"\Row Mode;T@o;;[I"2Set a table to row mode with method #by_row!:;To;;[I"2source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" ;TI".table = CSV.parse(source, headers: true) ;TI";table.by_row! # => #<CSV::Table mode:row row_count:4> ;T;0o;;[I"/Specify a single row by an \Integer index:;To;;[ I"# Get a row. ;TI"8table[1] # => #<CSV::Row "Name":"bar" "Value":"1"> ;TI"# Set a row, then get it. ;TI"<table[1] = CSV::Row.new(['Name', 'Value'], ['bam', 3]) ;TI"6table[1] # => #<CSV::Row "Name":"bam" "Value":3> ;T;0o;;[I",Specify a sequence of rows by a \Range:;To;;[ I"# Get rows. ;TI"atable[1..2] # => [#<CSV::Row "Name":"bam" "Value":3>, #<CSV::Row "Name":"baz" "Value":"2">] ;TI" # Set rows, then get them. ;TI"table[1..2] = [ ;TI"4 CSV::Row.new(['Name', 'Value'], ['bat', 4]), ;TI"4 CSV::Row.new(['Name', 'Value'], ['bad', 5]), ;TI"] ;TI"ttable[1..2] # => [["Name", #<CSV::Row "Name":"bat" "Value":4>], ["Value", #<CSV::Row "Name":"bad" "Value":5>]] ;T;0S; ; i;I"Column Mode;T@o;;[I"5Set a table to column mode with method #by_col!:;To;;[I"2source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" ;TI".table = CSV.parse(source, headers: true) ;TI";table.by_col! # => #<CSV::Table mode:col row_count:4> ;T;0o;;[I"+Specify a column by an \Integer index:;To;;[ I"# Get a column. ;TI"table[0] ;TI""# Set a column, then get it. ;TI"&table[0] = ['FOO', 'BAR', 'BAZ'] ;TI")table[0] # => ["FOO", "BAR", "BAZ"] ;T;0o;;[I",Specify a column by its \String header:;To;;[ I"# Get a column. ;TI".table['Name'] # => ["FOO", "BAR", "BAZ"] ;TI""# Set a column, then get it. ;TI"+table['Name'] = ['Foo', 'Bar', 'Baz'] ;TI".table['Name'] # => ["Foo", "Bar", "Baz"] ;T;0S; ; i;I"Mixed Mode;T@o;;[I"<In mixed mode, you can refer to either rows or columns:;To;;;;[o;;0;[o;;[I"'An \Integer index refers to a row.;To;;0;[o;;[I",A \Range index refers to multiple rows.;To;;0;[o;;[I"(A \String index refers to a column.;T@o;;[I";Set a table to mixed mode with method #by_col_or_row!:;To;;[I"2source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" ;TI".table = CSV.parse(source, headers: true) ;TI"Itable.by_col_or_row! # => #<CSV::Table mode:col_or_row row_count:4> ;T;0o;;[I"/Specify a single row by an \Integer index:;To;;[ I"# Get a row. ;TI"8table[1] # => #<CSV::Row "Name":"bar" "Value":"1"> ;TI"# Set a row, then get it. ;TI"<table[1] = CSV::Row.new(['Name', 'Value'], ['bam', 3]) ;TI"6table[1] # => #<CSV::Row "Name":"bam" "Value":3> ;T;0o;;[I",Specify a sequence of rows by a \Range:;To;;[I"# Get rows. ;TI"atable[1..2] # => [#<CSV::Row "Name":"bam" "Value":3>, #<CSV::Row "Name":"baz" "Value":"2">] ;TI" # Set rows, then get them. ;TI"<table[1] = CSV::Row.new(['Name', 'Value'], ['bat', 4]) ;TI"<table[2] = CSV::Row.new(['Name', 'Value'], ['bad', 5]) ;TI"ttable[1..2] # => [["Name", #<CSV::Row "Name":"bat" "Value":4>], ["Value", #<CSV::Row "Name":"bad" "Value":5>]] ;T;0o;;[I",Specify a column by its \String header:;To;;[ I"# Get a column. ;TI".table['Name'] # => ["foo", "bat", "bad"] ;TI""# Set a column, then get it. ;TI"+table['Name'] = ['Foo', 'Bar', 'Baz'] ;TI"-table['Name'] # => ["Foo", "Bar", "Baz"];T;0: @fileI"lib/csv/table.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[[ I" mode;TI"R;T:privateFI"lib/csv/table.rb;T[ I" table;T@&;F@'[ [[I"Enumerable;To;;[ ;@";0@'[[I" class;T[[:public[ [:protected[ [;[[I"new;T@'[I" instance;T[[;[ [;[ [;[[I"<<;T@'[I"==;T@'[I"[];T@'[I"[]=;T@'[I"by_col;T@'[I"by_col!;T@'[I"by_col_or_row;T@'[I"by_col_or_row!;T@'[I"by_row;T@'[I"by_row!;T@'[I"delete;T@'[I"delete_if;T@'[I"dig;T@'[I" each;T@'[I"headers;T@'[I"inspect;T@'[I" push;T@'[I" to_a;T@'[I"to_csv;T@'[I" to_s;T@'[I"values_at;T@'[[I"Forwardable;To;;[o;;[I"Array Delegation ###;T;@";0@'[U:RDoc::Context::Section[i 0o;;[ ;0;0[I"lib/csv/table.rb;TI"CSV;TcRDoc::NormalClass
💾 Save Changes
❌ Cancel