種類
- インスタンスメソッド (654)
- 特異メソッド (155)
- 文書 (78)
- モジュール関数 (22)
- クラス (11)
クラス
-
ARGF
. class (88) - Array (165)
- Enumerator (23)
-
Enumerator
:: ArithmeticSequence (6) -
Enumerator
:: Lazy (118) - Hash (56)
- Prime (22)
モジュール
- Enumerable (199)
- Find (22)
オブジェクト
- ENV (132)
キーワード
- Lazy (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - Ruby用語集 (11)
- chunk (22)
-
chunk
_ while (11) - collect (11)
-
delete
_ if (44) - detect (22)
- each (88)
-
each
_ key (22) -
each
_ line (44) -
each
_ pair (22) - filter (12)
- filter! (12)
- find (44)
-
find
_ all (22) -
find
_ index (66) - index (33)
-
keep
_ if (22) - lazy (22)
- map (11)
- new (18)
- partition (22)
- produce (5)
- reject (66)
- reject! (44)
- rindex (33)
-
ruby 1
. 9 feature (11) - select (22)
- select! (22)
-
slice
_ after (20) -
slice
_ before (33) -
slice
_ when (10)
検索結果
先頭5件
-
Enumerator
. new(size=nil) {|y| . . . } -> Enumerator (21171.0) -
Enumerator オブジェクトを生成して返します。与えられたブロックは Enumerator::Yielder オブジェクトを 引数として実行されます。
...
Enumerator オブジェクトを生成して返します。与えられたブロックは Enumerator::Yielder オブジェクトを
引数として実行されます。
生成された Enumerator オブジェクトに対して each を呼ぶと、この生成時に指定されたブロックを......する Enumerator オブジェクトの要素数を指定します。
Integer、Float::INFINITY、Proc オブジェク
ト、nil のいずれかを指定します。Enumerator#size の実
行時に参照されます。
//emlist[例][ruby]{
enum = Enumerator.new{|......y|
(1..10).each{|i|
y << i if i % 5 == 0
}
}
enum.each{|i| p i }
#=> 5
# 10
fib = Enumerator.new { |y|
a = b = 1
loop {
y << a
a, b = b, a + b
}
}
p fib.take(10) #=> [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
//}... -
Enumerator
. produce(initial = nil) { |prev| . . . } -> Enumerator (21171.0) -
与えられたブロックを呼び出し続ける、停止しない Enumerator を返します。 ブロックの戻り値が、次にブロックを呼び出す時に引数として渡されます。 initial 引数が渡された場合、最初にブロックを呼び出す時にそれがブロック 呼び出しの引数として渡されます。initial が渡されなかった場合は nil が 渡されます。
...与えられたブロックを呼び出し続ける、停止しない Enumerator を返します。
ブロックの戻り値が、次にブロックを呼び出す時に引数として渡されます。
initial 引数が渡された場合、最初にブロックを呼び出す時にそれがブロ......][ruby]{
# 1, 2, 3, 4, ... と続く Enumerator
Enumerator.produce(1, &:succ)
# next を呼ぶたびランダムな数値を返す Enumerator
Enumerator.produce { rand(10) }
# ツリー構造の祖先ノードを列挙する Enumerator
ancestors = Enumerator.produce(node) { |prev| node = prev.pare......nt or raise StopIteration }
enclosing_section = ancestors.find { |n| n.type == :section }
//}
このメソッドは Enumerable の各メソッドと組み合わせて使うことで、
while や until ループのような処理を実装できます。
例えば Enumerable#detect, Enumerable#slice_... -
Enumerator
. new(size=nil) {|y| . . . } -> Enumerator (21169.0) -
Enumerator オブジェクトを生成して返します。与えられたブロックは Enumerator::Yielder オブジェクトを 引数として実行されます。
...
Enumerator オブジェクトを生成して返します。与えられたブロックは Enumerator::Yielder オブジェクトを
引数として実行されます。
生成された Enumerator オブジェクトに対して each を呼ぶと、この生成時に指定されたブロックを......する Enumerator オブジェクトの要素数を指定します。
Integer、Float::INFINITY、Proc オブジェク
ト、nil のいずれかを指定します。Enumerator#size の実
行時に参照されます。
//emlist[例][ruby]{
enum = Enumerator.new{|......y|
(1..10).each{|i|
y << i if i % 5 == 0
}
}
enum.each{|i| p i }
#=> 5
# 10
fib = Enumerator.new { |y|
a = b = 1
loop {
y << a
a, b = b, a + b
}
}
p fib.take(10) #=> [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
//}... -
Enumerator
. new(obj , method = :each , *args) -> Enumerator (21116.0) -
オブジェクト obj について、 each の代わりに method という 名前のメソッドを使って繰り返すオブジェクトを生成して返します。 args を指定すると、 method の呼び出し時に渡されます。
...method イテレータメソッドの名前を表すシンボルまたは文字列
@param args イテレータメソッドの呼び出しに渡す任意個の引数
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new(str, :each_byte)
p enum.map {|b| '%02x' % b } # => ["78", "79", "7a"]
//}... -
Enumerator
:: ArithmeticSequence # ==(other) -> bool (21100.0) -
Enumerable::ArithmeticSequence として等しいか判定します。
Enumerable::ArithmeticSequence として等しいか判定します。
other が Enumerable::ArithmeticSequence で
begin, end, step, exclude_end? が等しい時に
true を返します。
@param other 自身と比較する Enumerable::ArithmeticSequence -
Enumerator
:: Lazy # chunk {|elt| . . . } -> Enumerator :: Lazy (3148.0) -
Enumerable#chunk と同じですが、配列ではなく Enumerator::Lazy を返します。
...unk と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.chunk{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007f8bf18118f0>:each>>
1.step.lazy.chunk{ |n| n % 3 == 0 }.take(5).force
# => [[false, [1, 2]],... -
Enumerator
:: Lazy # chunk(initial _ state) {|elt , state| . . . } -> Enumerator :: Lazy (3148.0) -
Enumerable#chunk と同じですが、配列ではなく Enumerator::Lazy を返します。
...unk と同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.chunk{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007f8bf18118f0>:each>>
1.step.lazy.chunk{ |n| n % 3 == 0 }.take(5).force
# => [[false, [1, 2]],... -
Enumerator
:: Lazy # slice _ after {|elt| bool } -> Enumerator :: Lazy (3148.0) -
Enumerable#slice_after と同じですが、配列ではなく Enumerator::Lazy を返します。
...同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_after { |e| e % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007fd73980e6f8>:each>>
1.step.lazy.slice_after { |e| e % 3 == 0 }.take(5).force
# => [[1, 2, 3],... -
Enumerator
:: Lazy # slice _ after(pattern) -> Enumerator :: Lazy (3148.0) -
Enumerable#slice_after と同じですが、配列ではなく Enumerator::Lazy を返します。
...同じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_after { |e| e % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007fd73980e6f8>:each>>
1.step.lazy.slice_after { |e| e % 3 == 0 }.take(5).force
# => [[1, 2, 3],... -
Enumerator
:: Lazy # slice _ when {|elt _ before , elt _ after| bool } -> Enumerator :: Lazy (3147.0) -
Enumerable#slice_when と同じですが、配列ではなく Enumerator::Lazy を返します。
...すが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_when { |i, j| (i + j) % 5 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007fce84118348>:each>>
1.step.lazy.slice_when { |i, j| (i + j) % 5 == 0 }.take(5).force
# => [[... -
Enumerator
:: Lazy # slice _ before {|elt| bool } -> Enumerator :: Lazy (3143.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
...じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>
1.step.lazy.slice_before { |e| e % 3 == 0 }.take(5).force
# => [[1, 2], [3,... -
Enumerator
:: Lazy # slice _ before(initial _ state) {|elt , state| bool } -> Enumerator :: Lazy (3143.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
...じですが、配列ではなく Enumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>
1.step.lazy.slice_before { |e| e % 3 == 0 }.take(5).force
# => [[1, 2], [3,...