るりまサーチ

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

別のキーワード

  1. _builtin to_a
  2. matrix to_a
  3. to_a
  4. dbm to_a
  5. argf.class to_a

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

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

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

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

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

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

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

@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。

//emlist[例][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...
...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, MatchData#offset...

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

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

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

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

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

@param n 部分文字列を指定する数値...
...@raise IndexError 範囲外の n を指定した場合に発生します。

@see MatchData#begin, MatchData#end...
...@raise IndexError 範囲外の n を指定した場合に発生します。

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

DateTime#offset -> Rational (24302.0)

時差を返します。

時差を返します。

Enumerable#each_with_index(*args) {|item, index| ... } -> self (18519.0)

要素とそのインデックスをブロックに渡して繰り返します。

...繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args イテレータメソッド (each など) にそのま...
...].each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}

//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}

@see Enumerator#with_index...

DateTime#new_offset(offset = 0) -> DateTime (18509.0)

self を複製して、その時差を設定しなおします。 引数を省略した場合は、零 (協定世界時) になります。

...self を複製して、その時差を設定しなおします。
引数を省略した場合は、零 (協定世界時) になります。

D
ateTime.new も参照してください。

@param offset 時差...

絞り込み条件を変える

Enumerable#each_with_index(*args) -> Enumerator (18319.0)

要素とそのインデックスをブロックに渡して繰り返します。

...繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args イテレータメソッド (each など) にそのま...
...].each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}

//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}

@see Enumerator#with_index...

Enumerator::Lazy#with_index(offset = 0) -> Enumerator::Lazy (15431.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

...クスは offset から始まります。

ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。

//emlist[][ruby]{
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
# 2:b
# 3:c
//}

@see Enumerator#with_index...

Enumerator::Lazy#with_index(offset = 0) {|(*args), idx| ... } -> Enumerator::Lazy (15431.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

...クスは offset から始まります。

ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。

//emlist[][ruby]{
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
# 2:b
# 3:c
//}

@see Enumerator#with_index...

Enumerator#with_index(offset = 0) -> Enumerator (15425.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

...ンデックスは offset から始まります。

ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。

//emlist[例][ruby]{
str = "xyz"

enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [12...
...0, 0]
# [121, 1]
# [122, 2]

require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|", 1]
# ["bar|", 2]
# ["baz", 3]
//}


生成時のパラメータに従って、要素にインデックスを添えてブロックを繰...
...り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。...

Enumerator#with_index(offset = 0) {|(*args), idx| ... } -> object (15425.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

...ンデックスは offset から始まります。

ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。

//emlist[例][ruby]{
str = "xyz"

enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [12...
...0, 0]
# [121, 1]
# [122, 2]

require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|", 1]
# ["bar|", 2]
# ["baz", 3]
//}


生成時のパラメータに従って、要素にインデックスを添えてブロックを繰...
...り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。...

絞り込み条件を変える

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

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

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

n
ameの名前付きグループにマッチした部分文字列がなければ
[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...
<< 1 2 3 > >>