るりまサーチ

最速Rubyリファレンスマニュアル検索!
10件ヒット [1-10件を表示] (0.011秒)
トップページ > モジュール:Enumerable[x] > クエリ:Enumerable#slice_before[x]

ライブラリ

キーワード

検索結果

Enumerable#slice_before {|elt| bool } -> Enumerator (23001)

パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。

...の手前で分割していきます。
最初の要素の評価は無視されます。

各チャンクは配列として表現されます。

Enumerable
#map のようなメソッドを使うこともできます。

# 偶数要素をチャンクの先頭と見なす
[0,2,4,1,2,4,5,3,1,4,2...
...f.slice_before(emp: true) {|line,h|
prevemp = h[:emp]
h[:emp] = line == "\n"
prevemp && line.start_with?("From ")
}.each {|mail|
mail.pop if mail.last == "\n"
pp mail
}
}

@param initial_state 状態を保持するオブジェクト
@see Enumerable#chunk...

Enumerable#slice_before(initial_state) {|elt, state| bool } -> Enumerator (23001)

パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。

...の手前で分割していきます。
最初の要素の評価は無視されます。

各チャンクは配列として表現されます。

Enumerable
#map のようなメソッドを使うこともできます。

# 偶数要素をチャンクの先頭と見なす
[0,2,4,1,2,4,5,3,1,4,2...
...f.slice_before(emp: true) {|line,h|
prevemp = h[:emp]
h[:emp] = line == "\n"
prevemp && line.start_with?("From ")
}.each {|mail|
mail.pop if mail.last == "\n"
pp mail
}
}

@param initial_state 状態を保持するオブジェクト
@see Enumerable#chunk...

Enumerable#slice_before(pattern) -> Enumerator (23001)

パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。

...の手前で分割していきます。
最初の要素の評価は無視されます。

各チャンクは配列として表現されます。

Enumerable
#map のようなメソッドを使うこともできます。

# 偶数要素をチャンクの先頭と見なす
[0,2,4,1,2,4,5,3,1,4,2...
...f.slice_before(emp: true) {|line,h|
prevemp = h[:emp]
h[:emp] = line == "\n"
prevemp && line.start_with?("From ")
}.each {|mail|
mail.pop if mail.last == "\n"
pp mail
}
}

@param initial_state 状態を保持するオブジェクト
@see Enumerable#chunk...

Enumerable#each_entry -> Enumerator (7)

ブロックを各要素に一度ずつ適用します。

...列として渡されます。

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 (7)

ブロックを各要素に一度ずつ適用します。

...列として渡されます。

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...

絞り込み条件を変える