るりまサーチ

最速Rubyリファレンスマニュアル検索!
196件ヒット [1-100件を表示] (0.115秒)

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

MatchData#offset(name) -> [Integer, Integer] | [nil, nil] (18299.0)

name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返 します。

...列 [start, end] を返
します。

//emlist[例][ruby]{
[ self.begin(name), self.end(name) ]
//}

と同じです。nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返します。

@
param name 名前(シンボルか文字列)

@
raise IndexError 正規...
...st[例][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?/ =~ "2021年1月"
p $~.offset('year') # => [0, 4]
p $~.offset(:year) # => [0, 4]
p $~.offset('month') # => [5, 6]
p $~.offset(:month) # => [5, 6]
p $~.offset('day') # => [nil, nil]
p $~.offset('century') # =...
...> `offset': undefined group name reference: century (IndexError)
//}

@
see MatchData#begin, MatchData#end...
...> `offset': undefined group name reference: century (IndexError)
//}

@
see MatchData#begin, MatchData#end, MatchData#offset...

MatchData#offset(n) -> [Integer, Integer] | [nil, nil] (18254.0)

n 番目の部分文字列のオフセットの配列 [start, end] を返 します。

...ットの配列 [start, end] を返
します。

//emlist[例][ruby]{
[ self.begin(n), self.end(n) ]
//}

と同じです。n番目の部分文字列がマッチしていなければ
[nil, nil] を返します。

@
param n 部分文字列を指定する数値

@
raise IndexError 範囲外の n を...
...指定した場合に発生します。

@
see MatchData#begin, MatchData#end...
...指定した場合に発生します。

@
see MatchData#begin, MatchData#end, MatchData#offset...

String#byterindex(pattern, offset = self.bytesize) -> Integer | nil (9284.0)

文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。

...イト単位のインデックス offset から左に向かって pattern を探索します。
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。

引数 pattern は探索する部分文字列ま...
...たは正規表現で指定します。

offset
が負の場合は、文字列の末尾から数えた位置から探索します。

byterindex と String#byteindex とでは、探索方向だけが逆になります。
完全に左右が反転した動作をするわけではありません。
...
...emlist[String#byteindex の場合][ruby]{
p "stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}

//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex("i...

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

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

...、Encoding::Converter#primitive_convert が唯一の方法になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param destination_by...
...
@
param options 変換の詳細を指定する定数やハッシュ
@
return 変換結果を表す 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::AFTER_OUTPUT

戻り値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full
* :source_b...

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

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

...、Encoding::Converter#primitive_convert が唯一の方法になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param destination_by...
...
@
param options 変換の詳細を指定する定数やハッシュ
@
return 変換結果を表す 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::AFTER_OUTPUT

戻り値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full
* :source_b...

絞り込み条件を変える

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

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

...、Encoding::Converter#primitive_convert が唯一の方法になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param destination_by...
...
@
param options 変換の詳細を指定する定数やハッシュ
@
return 変換結果を表す 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::AFTER_OUTPUT

戻り値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full
* :source_b...

IO#pwrite(string, offset) -> Integer (6366.0)

stringをoffsetの位置にpwrite()システムコールを使って書き込みます。

...stringをoffsetの位置にpwrite()システムコールを使って書き込みます。

IO#seekとIO#writeの組み合わせと比べて、アトミックな操作に
なるという点が優れていて、複数スレッド/プロセスから同じIOオブジェクトを
様々な位置から読...
...ァリングもバイパスします。

@
param string 書き込む文字列を指定します。
@
param offset ファイルポインタを変えずに書き込む位置を指定します。

@
return 書き込んだバイト数を返します。

@
raise Errno::EXXX シークまたは書き込みが...
...失敗した場合に発生します。
@raise NotImplementedError システムコールがサポートされていない OS で発生します。

//emlist[例][ruby]{
File.open("testfile", "w") do |f|
f.pwrite("ABCDEF", 3) # => 6
end

File.read("testfile") # => "\u0000\u0000\u0000ABCDEF"
/...

IO#pread(maxlen, offset, outbuf = "") -> string (6256.0)

preadシステムコールを使ってファイルポインタを変更せずに、また現在のファイルポインタに 依存せずにmaxlenバイト読み込みます。

...preadシステムコールを使ってファイルポインタを変更せずに、また現在のファイルポインタに
依存せずにmaxlenバイト読み込みます。

IO#seekとIO#readの組み合わせと比べて、アトミックな操作に
なるという点が優れていて、複...
...バイパスします。

@
param maxlen 読み込むバイト数を指定します。
@
param offset 読み込み開始位置のファイルの先頭からのオフセットを指定します。
@
param outbuf データを受け取る String を指定します。

@
raise Errno::EXXX シークまたは...
...す。
@
raise EOFError EOF に到達した時に発生します。
@
raise NotImplementedError システムコールがサポートされていない OS で発生します。

//emlist[例][ruby]{
File.write("testfile", "This is line one\nThis is line two\n")
File.open("testfile") do |f|
p f.read...

MatchData#byteoffset(name) -> [Integer, Integer] | [nil, nil] (6247.0)

name という名前付きグループに対応する部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。

...バイト単位のオフセットの
配列 [start, end] を返します。

nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返します。

@
param name 名前(シンボルか文字列)

@
raise IndexError 正規表現中で定義されていない name...
...

//emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?/ =~ "2021年1月"
p $~.byteoffset('year') # => [0, 4]
p $~.byteoffset(:year) # => [0, 4]
p $~.byteoffset('month') # => [7, 8]
p $~.byteoffset(:month) # => [7, 8]
p $~.byteoffset('day') # => [nil,...
...nil]
p $~.byteoffset('century') # => `offset': undefined group name reference: century (IndexError)
//}

@
see MatchData#offset...

MatchData#byteoffset(n) -> [Integer, Integer] | [nil, nil] (6232.0)

n 番目の部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。

...のオフセットの
配列 [start, end] を返します。

n番目の部分文字列がマッチしていなければ [nil, nil] を返します。

@
param n 部分文字列を指定する数値

@
raise IndexError 範囲外の n を指定した場合に発生します。

@
see MatchData#offset...

絞り込み条件を変える

String#byteindex(pattern, offset = 0) -> Integer | nil (3272.0)

文字列の offset から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。

...文字列の offset から右に向かって pattern を検索し、
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。

引数 pattern は探索する部分文字列または正規表現で指定...
...索します。

@
param pattern 探索する部分文字列または正規表現
@
param offset 探索を開始するバイト単位のオフセット

@
raise IndexError オフセットが文字列の境界以外をさしているときに発生します。

//emlist[例][ruby]{
'foo'.byteinde...
...'o', -3) # => 1
'foo'.byteindex('o', -4) # => nil

'あいう'.byteindex('う') # => 6
'あいう'.byteindex('う', 3) # => 6
'あいう'.byteindex('う', -3) # => 6
'あいう'.byteindex('う', 1) # offset 1 does not land on character boundary (IndexError)
//}

@
see String#index, String#byterindex...

CSV::Row#[]=(header_or_index, value) (3267.0)

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

...

@
param header_or_index ヘッダの名前かインデックスを指定します。

@
param value 値を指定します。

//emlist[例 ヘッダの名前で指定][ruby]{
r
equire "csv"

r
ow = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])

r
ow["header1"] # => "row1_1"
r
ow["header1"]...
...ed"
r
ow["header1"] # => "updated"
//}

//emlist[例 ヘッダの index で指定][ruby]{
r
equire "csv"

r
ow = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])

r
ow["header1"] # => "row1_1"
r
ow[0] = "updated"
r
ow["header1"] # => "updated"
//}

//emlist[例 ヘッダの名前と offset...
...指定][ruby]{
r
equire "csv"

r
ow = CSV::Row.new(["header1", "header2", "header1"], ["row1_1", "row1_2", "row1_3"])

r
ow # => #<CSV::Row "header1":"row1_1" "header2":"row1_2" "header1":"row1_3">
r
ow["header1", 1] = "updated"
r
ow # => #<CSV::Row "header1":"row1_1" "header2":"row1_2" "header1":"upda...
<< 1 2 > >>