るりまサーチ

最速Rubyリファレンスマニュアル検索!
322件ヒット [1-100件を表示] (0.105秒)
トップページ > クエリ:l[x] > クエリ:RUBY[x] > クエリ:convert[x]

別のキーワード

  1. kernel $-l
  2. _builtin $-l
  3. matrix l
  4. lupdecomposition l
  5. $-l kernel

ライブラリ

モジュール

検索結果

<< 1 2 3 ... > >>

CSV#convert {|field, field_info| ... } (18333.0)

引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別 のオブジェクトへと変換します。

...ールドを渡して文字列から別
のオブジェクトへと変換します。

引数 name を指定した場合は、組み込みの CSV::Converters を変換器
として利用するために使います。また、独自の変換器を追加することもできま
す。

ブロックパ...
...ールドと CSV::FieldInfo のインス
タンスを受け取ります。ブロックは変換後の値かフィールドそのものを返さな
ければなりません。

@param name 変換器の名前を指定します。

//emlist[例 name で Converter を指定][ruby]{
require "csv"

csv =...
....convert(:date)
csv.read # => 2018-07-09 ((2458309j,0s,0n),+0s,2299161j)>, #<Date: 2018-07-10 ((2458310j,0s,0n),+0s,2299161j)>
//}

//emlist[例 ブロックを指定][ruby]{
require "csv"

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

CSV#convert {|field| ... } (18233.0)

引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別 のオブジェクトへと変換します。

...ールドを渡して文字列から別
のオブジェクトへと変換します。

引数 name を指定した場合は、組み込みの CSV::Converters を変換器
として利用するために使います。また、独自の変換器を追加することもできま
す。

ブロックパ...
...ールドと CSV::FieldInfo のインス
タンスを受け取ります。ブロックは変換後の値かフィールドそのものを返さな
ければなりません。

@param name 変換器の名前を指定します。

//emlist[例 name で Converter を指定][ruby]{
require "csv"

csv =...
....convert(:date)
csv.read # => 2018-07-09 ((2458309j,0s,0n),+0s,2299161j)>, #<Date: 2018-07-10 ((2458310j,0s,0n),+0s,2299161j)>
//}

//emlist[例 ブロックを指定][ruby]{
require "csv"

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

CSV#unconverted_fields? -> bool (12212.0)

パースした結果が unconverted_fields というメソッドを持つ場合に真を返します。 そうでない場合は、偽を返します。

...ースした結果が unconverted_fields というメソッドを持つ場合に真を返します。
そうでない場合は、偽を返します。


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

csv = CSV.new("date1,date2\n2018-07-09,2018-07-10")
csv.unconverted_fields? # => nil
csv = CSV.new("date1,date2...
...\n2018-07-09,2018-07-10", unconverted_fields: false)
csv.unconverted_fields? # => false
csv = CSV.new("date1,date2\n2018-07-09,2018-07-10", headers: true, unconverted_fields: true)
csv.unconverted_fields? # => true
csv.convert(:date)
row = csv.readline
row.fields # => [#<Date: 2018-07-0...
...9 ((2458309j,0s,0n),+0s,2299161j)>, #<Date: 2018-07-10 ((2458310j,0s,0n),+0s,2299161j)>]
row.unconverted_fields # => ["2018-07-09", "2018-07-10"]
//}

@see CSV.new...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer) -> Symbol (9222.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字...
...Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT
Encoding::Converter::...
...値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full
* :source_buffer_empty
* :finished

//emlist[][ruby]{
ec = Encoding::Converter.new("UTF-8", "EUC-JP")
src = "abc\x81あいう\u{20...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset) -> Symbol (9222.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字...
...Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT
Encoding::Converter::...
...値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full
* :source_buffer_empty
* :finished

//emlist[][ruby]{
ec = Encoding::Converter.new("UTF-8", "EUC-JP")
src = "abc\x81あいう\u{20...

絞り込み条件を変える

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize) -> Symbol (9222.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字...
...Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT
Encoding::Converter::...
...値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full
* :source_buffer_empty
* :finished

//emlist[][ruby]{
ec = Encoding::Converter.new("UTF-8", "EUC-JP")
src = "abc\x81あいう\u{20...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, options) -> Symbol (9222.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字...
...Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT
Encoding::Converter::...
...値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full
* :source_buffer_empty
* :finished

//emlist[][ruby]{
ec = Encoding::Converter.new("UTF-8", "EUC-JP")
src = "abc\x81あいう\u{20...

Encoding::Converter#last_error -> Exception | nil (9118.0)

直前に変換器で発生した例外に相当する例外オブジェクトを返します。 直前の変換で例外が発生していない場合は nil を返します。

...nil を返します。

//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "iso-8859-1")
p ec.primitive_convert(src="\xf1abcd", dst="") #=> :invalid_byte_sequence
p ec.last_error #=> #<Encoding::InvalidByteSequenceError: "\xF1" followed by "a" on UTF-8>
p ec.primitive_convert(src, d...
...st, nil, 1) #=> :destination_buffer_full
p ec.last_error #=> nil
//}...

Encoding::Converter#replacement=(string) (9112.0)

置換文字を設定します。

...置換文字を設定します。

@param string 変換器に設定する置換文字

//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace)
ec.replacement = "<undef>"
p ec.convert("a \u3042 b") #=> "a <undef> b"
//}...

Encoding::Converter#replacement -> String (9106.0)

変換器に設定されている置換文字を返します。

...器に設定されている置換文字を返します。

@return 変換器に設定されている置換文字

//emlist[][ruby]{
ec = Encoding::Converter.new("euc-jp", "us-ascii")
p ec.replacement #=> "?"

ec = Encoding::Converter.new("euc-jp", "utf-8")
p ec.replacement #=> "\uFFFD"
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>