クラス
- CSV (8)
-
CSV
:: FieldInfo (1)
モジュール
- Kernel (2)
キーワード
- converters (1)
-
convertible
_ int (2) -
header
_ convert (3) -
header
_ converters (1)
検索結果
先頭5件
-
CSV
# convert {|field , field _ info| . . . } (72829.0) -
引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別 のオブジェクトへと変換します。
引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別
のオブジェクトへと変換します。
引数 name を指定した場合は、組み込みの CSV::Converters を変換器
として利用するために使います。また、独自の変換器を追加することもできま
す。
ブロックパラメータを一つ受け取るブロックを与えた場合は、そのブロックは
フィールドを受け取ります。ブロックパラメータを二つ受け取るブロックを与
えた場合は、そのブロックは、フィールドと CSV::FieldInfo のインス
タンスを受け取ります。ブロックは変換後の値かフィールドそのものを返さな
ければなりません。
... -
CSV
# convert {|field| . . . } (72829.0) -
引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別 のオブジェクトへと変換します。
引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別
のオブジェクトへと変換します。
引数 name を指定した場合は、組み込みの CSV::Converters を変換器
として利用するために使います。また、独自の変換器を追加することもできま
す。
ブロックパラメータを一つ受け取るブロックを与えた場合は、そのブロックは
フィールドを受け取ります。ブロックパラメータを二つ受け取るブロックを与
えた場合は、そのブロックは、フィールドと CSV::FieldInfo のインス
タンスを受け取ります。ブロックは変換後の値かフィールドそのものを返さな
ければなりません。
... -
CSV
# convert(name) (72829.0) -
引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別 のオブジェクトへと変換します。
引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別
のオブジェクトへと変換します。
引数 name を指定した場合は、組み込みの CSV::Converters を変換器
として利用するために使います。また、独自の変換器を追加することもできま
す。
ブロックパラメータを一つ受け取るブロックを与えた場合は、そのブロックは
フィールドを受け取ります。ブロックパラメータを二つ受け取るブロックを与
えた場合は、そのブロックは、フィールドと CSV::FieldInfo のインス
タンスを受け取ります。ブロックは変換後の値かフィールドそのものを返さな
ければなりません。
... -
CSV
:: FieldInfo # header -> String | nil (63697.0) -
利用可能な場合はヘッダを表す文字列を返します。
利用可能な場合はヘッダを表す文字列を返します。
//emlist[例][ruby]{
require 'csv'
csv = 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,... -
CSV
# header _ convert {|field , field _ info| . . . } (55222.0) -
CSV#convert に似ていますが、ヘッダ行用のメソッドです。
CSV#convert に似ていますが、ヘッダ行用のメソッドです。
このメソッドはヘッダ行を読み込む前に呼び出さなければなりません。
@param name 変換器の名前を指定します。
//emlist[例 name を指定][ruby]{
require "csv"
csv = CSV.new("header1,header2\nrow1_1,row1_2", headers: true)
csv.header_convert(:symbol)
csv.first.headers # => [:header1, :header2]
//}
//emlist[例 ブロックを指定][... -
CSV
# header _ convert {|field| . . . } (55222.0) -
CSV#convert に似ていますが、ヘッダ行用のメソッドです。
CSV#convert に似ていますが、ヘッダ行用のメソッドです。
このメソッドはヘッダ行を読み込む前に呼び出さなければなりません。
@param name 変換器の名前を指定します。
//emlist[例 name を指定][ruby]{
require "csv"
csv = CSV.new("header1,header2\nrow1_1,row1_2", headers: true)
csv.header_convert(:symbol)
csv.first.headers # => [:header1, :header2]
//}
//emlist[例 ブロックを指定][... -
CSV
# header _ convert(name) (55222.0) -
CSV#convert に似ていますが、ヘッダ行用のメソッドです。
CSV#convert に似ていますが、ヘッダ行用のメソッドです。
このメソッドはヘッダ行を読み込む前に呼び出さなければなりません。
@param name 変換器の名前を指定します。
//emlist[例 name を指定][ruby]{
require "csv"
csv = CSV.new("header1,header2\nrow1_1,row1_2", headers: true)
csv.header_convert(:symbol)
csv.first.headers # => [:header1, :header2]
//}
//emlist[例 ブロックを指定][... -
CSV
# header _ converters -> Array (55015.0) -
現在有効なヘッダ用変換器のリストを返します。
現在有効なヘッダ用変換器のリストを返します。
組込みの変換器は名前を返します。それ以外は、オブジェクトを返します。
//emlist[例][ruby]{
require "csv"
csv = CSV.new("HEADER1,HEADER2\nrow1_1,row1_2", headers: true, header_converters: CSV::HeaderConverters.keys)
csv.header_converters # => [:downcase, :symbol]
csv.read.to_a # => header2], ["row1_1",... -
Kernel
# convertible _ int(type , headers = nil , opts = nil) (36952.0) -
Returns the convertible integer type of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. _Convertible_ means actually same type, or typedefed from same type. If the +type+ is a integer type and _convertible_ type is found, following macros are passed as preprocessor constants to the compiler using the +type+ name, in uppercase. * 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X' is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP, where 'TYP' is the +type+ name in uppercase with replacing '_t' suffix with 'T', followed by '=X' where 'X' is the macro name to convert +type+ to +Integer+ object, and vice versa. For example, if foobar_t is defined as unsigned long, then convertible_int("foobar_t") would return "unsigned long", and define macros: #define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG
Returns the convertible integer type of the given +type+. You may
optionally specify additional +headers+ to search in for the +type+.
_Convertible_ means actually same type, or typedefed from same type.
If the +type+ is a integer type and _convertible_ type is found,
following macros are p... -
Kernel
# convertible _ int(type , headers = nil , opts = nil) { . . . } (36952.0) -
Returns the convertible integer type of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. _Convertible_ means actually same type, or typedefed from same type. If the +type+ is a integer type and _convertible_ type is found, following macros are passed as preprocessor constants to the compiler using the +type+ name, in uppercase. * 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X' is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP, where 'TYP' is the +type+ name in uppercase with replacing '_t' suffix with 'T', followed by '=X' where 'X' is the macro name to convert +type+ to +Integer+ object, and vice versa. For example, if foobar_t is defined as unsigned long, then convertible_int("foobar_t") would return "unsigned long", and define macros: #define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG
Returns the convertible integer type of the given +type+. You may
optionally specify additional +headers+ to search in for the +type+.
_Convertible_ means actually same type, or typedefed from same type.
If the +type+ is a integer type and _convertible_ type is found,
following macros are p... -
CSV
# converters -> Array (36640.0) -
現在の変換器のリストを返します。
現在の変換器のリストを返します。
//emlist[例][ruby]{
require "csv"
csv = CSV.new("header1,header2\nrow1_1,row1_2", converters: CSV::Converters.keys)
csv.converters # => [:integer, :float, :integer, :float, :date, :date_time, :date_time, :integer, :float]
//}
@see CSV::Converters