ライブラリ
クラス
-
ARGF
. class (29) - Array (154)
- Complex (22)
- Date (22)
- Dir (17)
- Enumerator (121)
-
Enumerator
:: ArithmeticSequence (12) -
Enumerator
:: Chain (6) -
Enumerator
:: Lazy (175) -
Enumerator
:: Yielder (27) - Hash (93)
- IO (95)
- Integer (11)
- Matrix (34)
- Numeric (51)
- Object (44)
- OpenStruct (11)
- Pathname (57)
- Prime (11)
-
Prime
:: PseudoPrimeGenerator (33) -
Psych
:: Nodes :: Node (11) -
REXML
:: Parent (44) - Range (29)
- String (62)
- StringIO (65)
- Struct (11)
- Vector (45)
-
Zlib
:: GzipReader (33)
モジュール
- Enumerable (258)
- TSort (20)
キーワード
- % (12)
- << (11)
- ascend (11)
- bytes (7)
- chunk (11)
-
chunk
_ while (11) - codepoints (21)
- collect (44)
- collect! (23)
- collect2 (11)
- compact (3)
-
delete
_ if (33) - denominator (11)
- descend (11)
- detect (11)
- drop (11)
-
drop
_ while (33) - each (154)
-
each
_ byte (44) -
each
_ char (11) -
each
_ child (28) -
each
_ codepoint (44) -
each
_ cons (11) -
each
_ entry (2) -
each
_ grapheme _ cluster (7) -
each
_ index (11) -
each
_ key (11) -
each
_ line (77) -
each
_ pair (33) -
each
_ slice (11) -
each
_ strongly _ connected _ component (10) -
each
_ strongly _ connected _ component _ from (10) -
each
_ value (11) -
each
_ with _ index (22) - eager (5)
-
enum
_ for (44) - feed (11)
-
filter
_ map (10) - find (22)
-
find
_ index (11) -
flat
_ map (22) - grep (11)
-
grep
_ v (9) -
group
_ by (11) - gsub (11)
- gsub! (11)
- index (11)
- inspect (12)
-
keep
_ if (22) - lazy (22)
- lines (7)
- map (55)
- map! (23)
-
max
_ by (22) -
next
_ values (11) - partition (11)
- peek (11)
-
peek
_ values (11) - permutation (11)
- reject (11)
- reject! (22)
-
repeated
_ combination (11) -
repeated
_ permutation (11) -
reverse
_ each (11) - rewind (11)
- rindex (11)
- select! (5)
-
slice
_ after (32) -
slice
_ before (33) -
slice
_ when (11) -
sort
_ by (11) - step (85)
-
to
_ enum (44) -
to
_ proc (5) - upto (22)
-
with
_ index (33) -
with
_ object (11) - yield (11)
- zip (22)
検索結果
先頭5件
-
Complex
# numerator -> Complex (21214.0) -
分子を返します。
...分子を返します。
//emlist[例][ruby]{
Complex('1/2+2/3i').numerator # => (3+4i)
Complex(3).numerator # => (3+0i)
//}
@see Complex#denominator... -
Array
# repeated _ permutation(n) -> Enumerator (12302.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
:: Yielder # to _ proc -> Proc (9207.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 (9201.0) -
Enumerable#compact と同じですが、配列ではなく Enumerator::Lazy を返します。
...Enumerable#compact と同じですが、配列ではなく Enumerator::Lazy を返します。... -
Enumerator
:: Lazy # drop(n) -> Enumerator :: Lazy (9201.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 (9201.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 (9201.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 (9201.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 (9201.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 (9201.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 (9143.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... -
Enumerator
# peek _ values -> Array (9131.0) -
Enumerator#next_values のように「次」のオブジェクトを 配列で返しますが、列挙状態を変化させません。
...Enumerator#next_values のように「次」のオブジェクトを
配列で返しますが、列挙状態を変化させません。
Enumerator#next, Enumerator#next_values のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり......StopIteration 例外を発生します。
このメソッドは Enumerator#next_values と同様
yield
と
yield nil
を区別するために使えます。
//emlist[例][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
end
e = o.to_enum
p e.peek_values #=> []
e.next
p e.peek......_values #=> [1]
p e.peek_values #=> [1]
e.next
p e.peek_values #=> [1, 2]
e.next
p e.peek_values # raises StopIteration
//}
@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#next_values, Enumerator#peek_values...