種類
- インスタンスメソッド (99)
- 文書 (19)
- クラス (11)
ライブラリ
- ビルトイン (110)
クラス
-
Enumerator
:: Lazy (33)
モジュール
- Enumerable (66)
キーワード
- Lazy (11)
-
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 2
. 3 . 0 (9) -
each
_ entry (22) -
slice
_ after (22)
検索結果
先頭5件
-
Enumerable
# slice _ before {|elt| bool } -> Enumerator (39168.0) -
パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。
...ャンクは配列として表現されます。
Enumerable#to_a や Enumerable#map のようなメソッドを使うこ
ともできます。
//emlist[例][ruby]{
# 偶数要素をチャンクの先頭と見なす
[0,2,4,1,2,4,5,3,1,4,2].slice_before(&:even?).to_a
# => [[0], [2], [4, 1], [2], [4,......2].slice_before(&:odd?).to_a
# => [[0, 2, 4], [1, 2, 4], [5], [3], [1, 4, 2]]
# ChangeLog のエントリーを順に取る
open("ChangeLog") {|f|
f.slice_before(/\A\S/).each {|e| pp e}
}
# 上と同じだが、パターンでなくブロックを使う
open("ChangeLog") {|f|
f.slice_before {|......を分割する
# これは一要素が複数行にまたがっている
IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) {|f|
f.lines.slice_before(/\AProp/).each {|lines| p lines }
}
#=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"]
# ["Properties on 'goruby.c':\n", " svn:eo... -
Enumerable
# slice _ before(pattern) -> Enumerator (39168.0) -
パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。
...ャンクは配列として表現されます。
Enumerable#to_a や Enumerable#map のようなメソッドを使うこ
ともできます。
//emlist[例][ruby]{
# 偶数要素をチャンクの先頭と見なす
[0,2,4,1,2,4,5,3,1,4,2].slice_before(&:even?).to_a
# => [[0], [2], [4, 1], [2], [4,......2].slice_before(&:odd?).to_a
# => [[0, 2, 4], [1, 2, 4], [5], [3], [1, 4, 2]]
# ChangeLog のエントリーを順に取る
open("ChangeLog") {|f|
f.slice_before(/\A\S/).each {|e| pp e}
}
# 上と同じだが、パターンでなくブロックを使う
open("ChangeLog") {|f|
f.slice_before {|......を分割する
# これは一要素が複数行にまたがっている
IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) {|f|
f.lines.slice_before(/\AProp/).each {|lines| p lines }
}
#=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"]
# ["Properties on 'goruby.c':\n", " svn:eo... -
Enumerable
# slice _ after {|elt| bool } -> Enumerator (21024.0) -
パターンがマッチした要素、もしくはブロックが真を返した要素を末尾の要素 としてチャンク化(グループ化)したものを繰り返す Enumerator を 返し ます。
..._a
#=> [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]]
p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last }
#=>["foo\n", "barbaz\n", "\n", "qux\n"]
//}
Enumerable#map のようなメソッドを使うこともできます。
@see Enumerable#chunk, Enumerable#slice_before... -
Enumerable
# slice _ after(pattern) -> Enumerator (21024.0) -
パターンがマッチした要素、もしくはブロックが真を返した要素を末尾の要素 としてチャンク化(グループ化)したものを繰り返す Enumerator を 返し ます。
..._a
#=> [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]]
p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last }
#=>["foo\n", "barbaz\n", "\n", "qux\n"]
//}
Enumerable#map のようなメソッドを使うこともできます。
@see Enumerable#chunk, Enumerable#slice_before... -
Enumerable
# each _ entry -> Enumerator (21018.0) -
ブロックを各要素に一度ずつ適用します。
...配列として渡されます。
//emlist[例][ruby]{
class Foo
include Enumerable
def each
yield 1
yield 1,2
end
end
Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}
ブロックを省略した場合は Enumerator が返されます。
@see Enumerable#slice_before... -
Enumerable
# each _ entry {|obj| block} -> self (21018.0) -
ブロックを各要素に一度ずつ適用します。
...配列として渡されます。
//emlist[例][ruby]{
class Foo
include Enumerable
def each
yield 1
yield 1,2
end
end
Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}
ブロックを省略した場合は Enumerator が返されます。
@see Enumerable#slice_before... -
Enumerator
:: Lazy # slice _ before {|elt| bool } -> Enumerator :: Lazy (18159.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
...
Enumerable#slice_before と同じですが、配列ではなく 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 }.t......ake(5).force
# => [[1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14]]
//}
@see Enumerable#slice_before... -
Enumerator
:: Lazy # slice _ before(initial _ state) {|elt , state| bool } -> Enumerator :: Lazy (18159.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
...
Enumerable#slice_before と同じですが、配列ではなく 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 }.t......ake(5).force
# => [[1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14]]
//}
@see Enumerable#slice_before... -
Enumerator
:: Lazy # slice _ before(pattern) -> Enumerator :: Lazy (18159.0) -
Enumerable#slice_before と同じですが、配列ではなく Enumerator::Lazy を返します。
...
Enumerable#slice_before と同じですが、配列ではなく 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 }.t......ake(5).force
# => [[1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14]]
//}
@see Enumerable#slice_before... -
NEWS for Ruby 2
. 2 . 0 (66.0) -
NEWS for Ruby 2.2.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...* 追加: Binding#receiver
* Dir
* 追加: Dir#fileno
* Enumerable
* 追加: Enumerable#slice_after
* 追加: Enumerable#slice_when
* 拡張: Enumerable#min, Enumerable#min_by, Enumerable#max, Enumerable#max_by
は複数の値を返すためのオプションをサ......返します。
=== 組み込みクラスの互換性 (機能追加とバグ修正を除く)
* Enumerable
* Enumerable#slice_before の状態管理は非推奨になりました
* Enumerable#chunk の状態管理は非推奨になりました
* GC
* 非互換: GC.stat のエント...