@@ -2506,27 +2506,26 @@ slicebefore_i(VALUE yielder, VALUE enumerator, int argc, VALUE *argv)
2506
2506
*
2507
2507
* Creates an enumerator for each chunked elements.
2508
2508
* The beginnings of chunks are defined by _pattern_ and the block.
2509
- * If _pattern_ === _elt_ returns true or
2510
- * the block returns true for the element,
2511
- * the element is beginning of a chunk.
2512
- *
2513
- * The === and block is called from the first element to the last element
2514
- * of _enum_.
2515
- * The result for the first element is ignored.
2516
- *
2517
- * The result enumerator yields the chunked elements as an array for +each+
2518
- * method.
2519
- * +each+ method can be called as follows.
2509
+
2510
+ * If <code>_pattern_ === _elt_</code> returns <code>true</code> or the block
2511
+ * returns <code>true</code> for the element, the element is beginning of a
2512
+ * chunk.
2513
+
2514
+ * The <code>===</code> and _block_ is called from the first element to the last
2515
+ * element of _enum_. The result for the first element is ignored.
2516
+
2517
+ * The result enumerator yields the chunked elements as an array.
2518
+ * So +each+ method can be called as follows:
2520
2519
*
2521
2520
* enum.slice_before(pattern).each { |ary| ... }
2522
2521
* enum.slice_before { |elt| bool }.each { |ary| ... }
2523
2522
* enum.slice_before(initial_state) { |elt, state| bool }.each { |ary| ... }
2524
2523
*
2525
- * Other methods of Enumerator class and Enumerable module,
2524
+ * Other methods of the Enumerator class and Enumerable module,
2526
2525
* such as map, etc., are also usable.
2527
2526
*
2528
2527
* For example, iteration over ChangeLog entries can be implemented as
2529
- * follows.
2528
+ * follows:
2530
2529
*
2531
2530
* # iterate over ChangeLog entries.
2532
2531
* open("ChangeLog") { |f|
@@ -2538,8 +2537,9 @@ slicebefore_i(VALUE yielder, VALUE enumerator, int argc, VALUE *argv)
2538
2537
* f.slice_before { |line| /\A\S/ === line }.each { |e| pp e }
2539
2538
* }
2540
2539
*
2541
- * "svn proplist -R" produces multiline output for each file.
2542
- * They can be chunked as follows:
2540
+ *
2541
+ * "svn proplist -R" produces multiline output for each file.
2542
+ * They can be chunked as follows:
2543
2543
*
2544
2544
* IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f|
2545
2545
* f.lines.slice_before(/\AProp/).each { |lines| p lines }
@@ -2567,15 +2567,14 @@ slicebefore_i(VALUE yielder, VALUE enumerator, int argc, VALUE *argv)
2567
2567
*
2568
2568
* However local variables are not appropriate to maintain state
2569
2569
* if the result enumerator is used twice or more.
2570
- * In such case, the last state of the 1st +each+ is used in 2nd +each+.
2571
- * _initial_state_ argument can be used to avoid this problem.
2570
+ * In such a case, the last state of the 1st +each+ is used in the 2nd +each+.
2571
+ * The _initial_state_ argument can be used to avoid this problem.
2572
2572
* If non-nil value is given as _initial_state_,
2573
- * it is duplicated for each " each" method invocation of the enumerator.
2573
+ * it is duplicated for each + each+ method invocation of the enumerator.
2574
2574
* The duplicated object is passed to 2nd argument of the block for
2575
2575
* +slice_before+ method.
2576
2576
*
2577
- * # word wrapping.
2578
- * # this assumes all characters have same width.
2577
+ * # Word wrapping. This assumes all characters have same width.
2579
2578
* def wordwrap(words, maxwidth)
2580
2579
* # if cols is a local variable, 2nd "each" may start with non-zero cols.
2581
2580
* words.slice_before(cols: 0) { |w, h|
@@ -2603,8 +2602,8 @@ slicebefore_i(VALUE yielder, VALUE enumerator, int argc, VALUE *argv)
2603
2602
* # 20
2604
2603
* # ----------
2605
2604
*
2606
- * mbox contains series of mails which start with Unix From line.
2607
- * So each mail can be extracted by slice before Unix From line.
2605
+ * mbox contains series of mails which start with Unix From line.
2606
+ * So each mail can be extracted by slice before Unix From line.
2608
2607
*
2609
2608
* # parse mbox
2610
2609
* open("mbox") { |f|
0 commit comments