るりまサーチ

最速Rubyリファレンスマニュアル検索!
22件ヒット [1-22件を表示] (0.063秒)
トップページ > 種類:インスタンスメソッド[x] > クエリ:first[x] > クラス:CSV::FieldInfo[x]

別のキーワード

  1. _builtin first
  2. range first
  3. array first
  4. enumerable first
  5. matrix first_minor

ライブラリ

キーワード

検索結果

CSV::FieldInfo#header -> String | nil (8.0)

利用可能な場合はヘッダを表す文字列を返します。

...CSV.new("date1,date2\n2018-07-09,2018-07-10", headers: true)
csv.convert do |field,field_info|
p field_info.header
Date.parse(field)
end
p csv.first

# => "date1"
# => "date2"
# => #<CSV::Row "date1":#<Date: 2018-07-09 ((2458309j,0s,0n),+0s,2299161j)> "date2":#<Date: 2018-07-10 ((2458310j,0s,0n...

CSV::FieldInfo#index -> Integer (8.0)

行内で何番目のフィールドかわかるゼロベースのインデックスを返します。

...= CSV.new("date1,date2\n2018-07-09,2018-07-10", headers: true)
csv.convert do |field,field_info|
p field_info.index
Date.parse(field)
end
p csv.first

# => 0
# => 1
# => #<CSV::Row "date1":#<Date: 2018-07-09 ((2458309j,0s,0n),+0s,2299161j)> "date2":#<Date: 2018-07-10 ((2458310j,0s,0n),+0s,229916...