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

class CSV::Row

クラス・モジュールの継承リスト: CSV::Row < Enumerable < Object < Kernel < BasicObject
extend: Forwardable

要約

CSV::Row は配列やハッシュに似ています。

配列のようにフィールドの順序を保持していて、複製する事もできます。また、ハッシュのように名前でフィールドにアクセスする事もできます。

ヘッダ行の処理が有効である場合は CSV から返される全ての行はこのクラスのインスタンスです。

以下のメソッドを Array に委譲します。

特異メソッド

定義 説明
new(headers, fields, header_row = false) -> CSV::Row

自身を初期化します。

インスタンスメソッド

定義 説明
self << arg -> self

自身に与えられたデータを追加します。

self == other -> bool

自身が other と同じヘッダやフィールドを持つ場合に真を返します。そうでない場合は偽を返します。

field(header_or_index, minimum_index = 0) -> object | nil
self[header_or_index, minimum_index = 0] -> object | nil

ヘッダの名前かインデックスで値を取得します。フィールドが見つからなかった場合は nil を返します。

self[header_or_index] = value

ヘッダの名前かインデックスでフィールドを探し、値をセットします。

self[header, offset] = value

ヘッダの名前でフィールドを探し、値をセットします。

delete(header_or_index, minimum_index = 0) -> [object, object] | nil

ヘッダの名前かインデックスで行からフィールドを削除するために使用します。

delete_if {|header, field| ... } -> self

与えられたブロックにヘッダとフィールドのペアを渡して評価します。評価した結果が真である場合に、その組を自身から削除します。

each {|header, field| ... } -> self

与えられたブロックにヘッダとフィールドの組を渡して評価します。

empty? -> bool

内部で保持している @row へ委譲します。

field?(data) -> bool

自身に与えられた値が含まれている場合は真を返します。そうでない場合は偽を返します。

field_row? -> bool

フィールド行であれば真を返します。そうでなければ偽を返します。

fields(*headers_and_or_indices) -> Array
values_at(*headers_and_or_indices) -> Array

与えられた引数に対応する値の配列を返します。

header?(name) -> bool
include?(name) -> bool

自身のヘッダに与えられた値が含まれている場合は真を返します。そうでない場合は偽を返します。

header_row? -> bool

ヘッダ行であれば真を返します。そうでなければ偽を返します。

headers -> Array

この行のヘッダのリストを返します。

index(header, minimum_index = 0) -> Integer

与えられたヘッダの名前に対応するインデックスを返します。

inspect -> String

ASCII 互換であるエンコーディングの文字列で自身の情報を返します。

length -> Integer
size -> Integer

Array#length, Array#size に委譲します。

push(*args) -> self

複数のフィールドを追加するためのショートカットです。

to_csv -> String
to_s -> String

自身を CSV な文字列として返します。ヘッダは使用しません。

to_hash -> Hash

自身をシンプルなハッシュに変換します。

protectedメソッド

定義 説明
row -> Array

同値性を比較するために使用する内部的なデータです。

継承したメソッド

! != __id__ __send__ instance_eval instance_exec method_missing singleton_method_added singleton_method_removed singleton_method_undefined all? any? chain chunk chunk_while collect collect_concat count cycle detect drop drop_while each_cons each_entry each_slice each_with_index each_with_object entries filter find_index first grep grep_v group_by include? inject lazy max max_by min min_by minmax minmax_by none? one? partition reject reverse_each slice_after slice_before slice_when sort sort_by sum take take_while to_h to_set uniq zip def_delegator def_delegators delegate !~ <=> === =~ _dump class clone define_singleton_method display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? itself marshal_dump marshal_load method methods nil? object_id pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods psych_to_yaml public_method public_methods public_send remove_instance_variable respond_to? respond_to_missing? send singleton_class singleton_method singleton_methods taint tainted? tap then to_ary to_int to_io to_proc to_regexp to_str trust untaint untrust untrusted? .yaml_tag ::ARGF ::ARGV ::DATA ::ENV ::FALSE ::NIL ::RUBY_COPYRIGHT ::RUBY_DESCRIPTION ::RUBY_ENGINE ::RUBY_ENGINE_VERSION ::RUBY_PATCHLEVEL ::RUBY_PLATFORM ::RUBY_RELEASE_DATE ::RUBY_REVISION ::RUBY_VERSION ::SCRIPT_LINES__ ::STDERR ::STDIN ::STDOUT ::TOPLEVEL_BINDING ::TRUE