U:RDoc::AnyMethod[iI"chunk_while:ETI"Enumerable#chunk_while;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"6Creates an enumerator for each chunked elements. ;TI"7The beginnings of chunks are defined by the block.;To:RDoc::Markup::BlankLine o;
; [
I";This method split each chunk using adjacent elements, ;TI"#_elt_before_ and _elt_after_, ;TI"!in the receiver enumerator. ;TI"IThis method split chunks between _elt_before_ and _elt_after_ where ;TI"*the block returns false
.;T@o;
; [I"IThe block is called the length of the receiver enumerator minus one.;T@o;
; [I"DThe result enumerator yields the chunked elements as an array. ;TI"/So +each+ method can be called as follows:;T@o:RDoc::Markup::Verbatim; [I"Jenum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... }
;T:@format0o;
; [I"BOther methods of the Enumerator class and Enumerable module, ;TI"2such as +to_a+, +map+, etc., are also usable.;T@o;
; [I"NFor example, one-by-one increasing subsequence can be chunked as follows:;T@o;; [I"+a = [1,2,4,9,10,11,12,15,16,19,20,21]
;TI"*b = a.chunk_while {|i, j| i+1 == j }
;TI"Ip b.to_a #=> [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]]
;TI"@c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" }
;TI"6p c #=> [[1, 2], [4], "9-12", [15, 16], "19-21"]
;TI"d = c.join(",")
;TI"&p d #=> "1,2,4,9-12,15,16,19-21"
;T;
0o;
; [I"GIncreasing (non-decreasing) subsequence can be chunked as follows:;T@o;; [I"(a = [0, 9, 2, 2, 3, 2, 7, 5, 9, 5]
;TI"+p a.chunk_while {|i, j| i <= j }.to_a
;TI"2#=> [[0, 9], [2, 2, 3], [2, 7], [5, 9], [5]]
;T;
0o;
; [I"8Adjacent evens and odds can be chunked as follows: ;TI"0(Enumerable#chunk is another way to do it.);T@o;; [I"(a = [7, 5, 9, 2, 0, 7, 9, 4, 2, 0]
;TI"7p a.chunk_while {|i, j| i.even? == j.even? }.to_a
;TI"0#=> [[7, 5, 9], [2, 0], [7, 9], [4, 2, 0]]
;T;
0o;
; [I"JEnumerable#slice_when does the same, except splitting when the block ;TI"=returns true
instead of false
.;T:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Genum.chunk_while {|elt_before, elt_after| bool } -> an_enumerator
;T0[ I"();T@FFI"Enumerable;TcRDoc::NormalModule00