るりまサーチ (Ruby 2.3.0)

最速Rubyリファレンスマニュアル検索!
4件ヒット [1-4件を表示] (0.106秒)

別のキーワード

  1. _builtin <<
  2. csv <<
  3. openssl <<
  4. rexml/document <<
  5. zlib <<

ライブラリ

キーワード

検索結果

CSV::Table#<<(row_or_array) -> self (54325.0)

自身の最後に新しい行を追加します。

...mlist[例][ruby]{
require "csv"

row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
table = CSV::Table.new([row1])
table << row2
table.to_a # => [["header1", "header2"], ["row1_1", "row1_2"], ["row2_1", "row2_2"]]
//}...

CSV::Table#==(other) -> bool (25.0)

自身の全ての行が比較対象と同じである場合は真を返します。 そうでない場合は偽を返します。

...自身の全ての行が比較対象と同じである場合は真を返します。
そうでない場合は偽を返します。

@param other CSV::Table を指定します。

//emlist[例][ruby]{
require "csv"

row1_1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row1_2 = CSV::Ro...
...w(["header1", "header2"], ["row1_1", "row1_2"])
row2_2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
table1 = CSV::Table.new([row1_1, row1_2])
table2 = CSV::Table.new([row2_1, row2_2])
table1 == table2 # => true
table2 << CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
tabl...

CSV::Table#empty? -> bool (25.0)

ヘッダーを除いて、データがないときに true を返します。

ヘッダーを除いて、データがないときに true を返します。

Array#empty? に委譲しています。

//emlist[][ruby]{
require 'csv'
csv = CSV.new("a,b\n", headers: true)
table = csv.read
p table.empty? # => true
table << [1, 2]
p table.empty? # => false
//}

@see Array#empty?

CSV::Table#push(*rows) -> self (25.0)

複数の行を追加するためのショートカットです。

...ire 'csv'
csv = CSV.new("a,b,c\n1,2,3", headers: true)
table = csv.read
rows = [
CSV::Row.new(table.headers, [4, 5, 6]),
[7, 8, 9]
]

table.push(*rows)
p table[0..2]
# => [#<CSV::Row "a":"1" "b":"2" "c":"3">, #<CSV::Row "a":4 "b":5 "c":6>, #<CSV::Row "a":7 "b":8 "c":9>]
//}

@see CSV::Table#<<...