種類
- インスタンスメソッド (1217)
- 特異メソッド (119)
- モジュール関数 (44)
- クラス (33)
クラス
-
ARGF
. class (29) - Array (154)
- Complex (22)
- Dir (53)
- Enumerator (144)
-
Enumerator
:: ArithmeticSequence (12) -
Enumerator
:: Chain (6) -
Enumerator
:: Lazy (175) -
Enumerator
:: Yielder (27) - Hash (93)
- IO (106)
- Integer (11)
- Numeric (51)
- Object (44)
- Range (29)
- String (62)
- Struct (11)
モジュール
- Enumerable (258)
- Kernel (22)
- ObjectSpace (22)
オブジェクト
- ENV (49)
キーワード
- % (12)
- << (11)
- Enumerator (11)
- Lazy (11)
- Numeric (11)
- chunk (11)
-
chunk
_ while (11) - codepoints (14)
- collect (22)
- collect! (11)
- compact (3)
-
delete
_ if (22) - denominator (11)
- detect (11)
- drop (11)
-
drop
_ while (33) - each (110)
-
each
_ byte (22) -
each
_ char (11) -
each
_ child (20) -
each
_ codepoint (33) -
each
_ cons (11) -
each
_ grapheme _ cluster (7) -
each
_ key (22) -
each
_ line (44) -
each
_ object (22) -
each
_ pair (33) -
each
_ slice (11) -
each
_ value (11) -
each
_ with _ index (11) - eager (5)
-
enum
_ for (44) - feed (11)
-
filter
_ map (10) - find (11)
-
find
_ index (11) -
flat
_ map (22) - foreach (33)
- grep (11)
-
grep
_ v (9) -
group
_ by (11) - gsub (22)
- gsub! (11)
- index (11)
- inspect (12)
-
keep
_ if (33) - lazy (22)
- loop (11)
- map (33)
- map! (11)
-
max
_ by (22) - new (18)
-
next
_ values (11) - partition (11)
- peek (11)
-
peek
_ values (11) - permutation (11)
- produce (5)
- reject (11)
- reject! (22)
-
repeated
_ combination (11) -
repeated
_ permutation (11) -
reverse
_ each (11) - rewind (11)
- rindex (11)
- select! (10)
-
slice
_ after (32) -
slice
_ before (33) -
slice
_ when (11) -
sort
_ by (11) - step (74)
-
to
_ enum (44) -
to
_ proc (5) - upto (11)
-
with
_ index (22) - yield (11)
- zip (22)
検索結果
先頭5件
-
Complex
# numerator -> Complex (21215.0) -
分子を返します。
...分子を返します。
//emlist[例][ruby]{
Complex('1/2+2/3i').numerator # => (3+4i)
Complex(3).numerator # => (3+0i)
//}
@see Complex#denominator... -
Array
# repeated _ permutation(n) -> Enumerator (12303.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...生成する Enumerator オブジェクトを返します。
@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数......a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=> [[]] # one perm......ロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}
@see Array#repeated_combination, Array#permutation... -
Enumerator
. produce(initial = nil) { |prev| . . . } -> Enumerator (9302.0) -
与えられたブロックを呼び出し続ける、停止しない Enumerator を返します。 ブロックの戻り値が、次にブロックを呼び出す時に引数として渡されます。 initial 引数が渡された場合、最初にブロックを呼び出す時にそれがブロック 呼び出しの引数として渡されます。initial が渡されなかった場合は nil が 渡されます。
...与えられたブロックを呼び出し続ける、停止しない Enumerator を返します。
ブロックの戻り値が、次にブロックを呼び出す時に引数として渡されます。
initial 引数が渡された場合、最初にブロックを呼び出す時にそれがブロ......ブロックが例外 StopIterationを投げた場合、繰り返しが終了します。
@param initial ブロックに最初に渡される値です。任意のオブジェクトを渡せます。
//emlist[例][ruby]{
# 1, 2, 3, 4, ... と続く Enumerator
Enumerator.produce(1, &:succ)
# next......ンダムな数値を返す Enumerator
Enumerator.produce { rand(10) }
# ツリー構造の祖先ノードを列挙する Enumerator
ancestors = Enumerator.produce(node) { |prev| node = prev.parent or raise StopIteration }
enclosing_section = ancestors.find { |n| n.type == :section }
//}
このメ... -
Enumerator
:: Yielder # to _ proc -> Proc (9208.0) -
Enumerator.new で使うメソッドです。
...Enumerator.new で使うメソッドです。
引数を Enumerator::Yielder#yield に渡す Proc を返します。
これは Enumerator::Yielder オブジェクトを他のメソッドにブロック引数と
して直接渡すために使えます。
//emlist[例][ruby]{
text = <<-END
Hello
こ......んにちは
END
enum = Enumerator.new do |y|
text.each_line(&y)
end
enum.each do |line|
p line
end
# => "Hello\n"
# "こんにちは\n"
//}... -
Enumerator
:: Lazy # compact -> Enumerator :: Lazy (9202.0) -
Enumerable#compact と同じですが、配列ではなく Enumerator::Lazy を返します。
...Enumerable#compact と同じですが、配列ではなく Enumerator::Lazy を返します。... -
Enumerator
:: Lazy # drop(n) -> Enumerator :: Lazy (9202.0) -
Enumerable#drop と同じですが、配列ではなくEnumerator::Lazy を返します。
...rop と同じですが、配列ではなくEnumerator::Lazy を返します。
@param n 要素数を指定します。
@raise ArgumentError n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
1.step.lazy.drop(3)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator:......1:step>>:drop(3)>
1.step.lazy.drop(3).take(10).force
# => [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
//}
@see Enumerable#drop... -
Enumerator
:: Lazy # drop _ while {|item| . . . } -> Enumerator :: Lazy (9202.0) -
Enumerable#drop_while と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#drop_while と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.drop_while { |i| i < 42 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:drop_while>
1.step.lazy.drop_while { |i| i < 42 }.take(10).force
# => [42......, 43, 44, 45, 46, 47, 48, 49, 50, 51]
//}
@see Enumerable#drop_while... -
Enumerator
:: Lazy # filter _ map {|item| . . . } -> Enumerator :: Lazy (9202.0) -
Enumerable#filter_map と同じですが、配列ではなく Enumerator::Lazy を返します。
...ap と同じですが、配列ではなく Enumerator::Lazy を返します。
@raise ArgumentError ブロックを指定しなかった場合に発生します。
//emlist[例][ruby]{
1.step.lazy.filter_map { |n| n * 2 if n.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: (1.step)>:filter_map......>
1.step.lazy.filter_map { |n| n * 2 if n.even? }.take(10).force
# => [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]
//}
@see Enumerable#filter_map... -
Enumerator
:: Lazy # grep(pattern) {|item| . . . } -> Enumerator :: Lazy (9202.0) -
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
...rep と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep(/\A(\d)\1+\z/)>
(100..Float::INFINITY).lazy.map(&......:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}
@see Enumerable#grep......:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}
@see Enumerable#grep, Enumerable#grep_v, Enumerator::Lazy#grep_v... -
Enumerator
:: Lazy # grep _ v(pattern) {|item| . . . } -> Enumerator :: Lazy (9202.0) -
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
...rep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep_v(/(\d).*\1/)>
(100..Float::INFINITY).lazy.map(&......:to_s).grep_v(/(\d).*\1/).take(15).force
# => ["102", "103", "104", "105", "106", "107", "108", "109", "120", "123", "124", "125", "126", "127", "128"]
//}
@see Enumerable#grep_v, Enumerable#grep, Enumerator::Lazy#grep... -
Enumerator
:: Lazy # zip(*lists) -> Enumerator :: Lazy (9202.0) -
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
...zip と同じですが、配列ではなくEnumerator::Lazy を返します。
ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip と
同じ挙動になります。
//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #<Enumerator:......:Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>
1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}
@see Enumerable#zip... -
Enumerator
# peek -> object (9144.0) -
「次」のオブジェクトを返しますが、列挙状態を変化させません。
...態を変化させません。
Enumerator#next のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり列挙状態を変更しません。
列挙が既に最後へ到達している場合は、StopIteration 例外を発生します......e = a.to_enum
p e.next #=> 1
p e.peek #=> 2
p e.peek #=> 2
p e.peek #=> 2
p e.next #=> 2
p e.next #=> 3
p e.next #raises StopIteration
//}
@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#next_values, Enumerator#peek_values...