Ruby 2.2.0 リファレンスマニュアル > ライブラリ一覧 > csvライブラリ > CSV::Tableクラス > ==

instance method CSV::Table#==

self == other -> bool[permalink][rdoc]

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

[PARAM] other:
CSV::Table を指定します。


require "csv"

row1_1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row1_2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
row2_1 = CSV::Row.new(["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"])
table1 == table2 # => false