Skip to content

Commit 8198cca

Browse files
committed
Merge branch 'pullreq/129' into trunk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 6a298a8 commit 8198cca

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Sun Aug 19 01:24:32 2012 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
2+
3+
* enum.c: fix docs. https://github.com/ruby/ruby/pull/129 by
4+
richardkmichael (Richard Michael).
5+
16
Sun Aug 19 00:47:26 2012 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
27

38
* lib/fileutils.rb: fix typo.

enum.c

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,27 +2506,26 @@ slicebefore_i(VALUE yielder, VALUE enumerator, int argc, VALUE *argv)
25062506
*
25072507
* Creates an enumerator for each chunked elements.
25082508
* 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:
25202519
*
25212520
* enum.slice_before(pattern).each { |ary| ... }
25222521
* enum.slice_before { |elt| bool }.each { |ary| ... }
25232522
* enum.slice_before(initial_state) { |elt, state| bool }.each { |ary| ... }
25242523
*
2525-
* Other methods of Enumerator class and Enumerable module,
2524+
* Other methods of the Enumerator class and Enumerable module,
25262525
* such as map, etc., are also usable.
25272526
*
25282527
* For example, iteration over ChangeLog entries can be implemented as
2529-
* follows.
2528+
* follows:
25302529
*
25312530
* # iterate over ChangeLog entries.
25322531
* open("ChangeLog") { |f|
@@ -2538,8 +2537,9 @@ slicebefore_i(VALUE yielder, VALUE enumerator, int argc, VALUE *argv)
25382537
* f.slice_before { |line| /\A\S/ === line }.each { |e| pp e }
25392538
* }
25402539
*
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:
25432543
*
25442544
* IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f|
25452545
* f.lines.slice_before(/\AProp/).each { |lines| p lines }
@@ -2567,15 +2567,14 @@ slicebefore_i(VALUE yielder, VALUE enumerator, int argc, VALUE *argv)
25672567
*
25682568
* However local variables are not appropriate to maintain state
25692569
* 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.
25722572
* 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.
25742574
* The duplicated object is passed to 2nd argument of the block for
25752575
* +slice_before+ method.
25762576
*
2577-
* # word wrapping.
2578-
* # this assumes all characters have same width.
2577+
* # Word wrapping. This assumes all characters have same width.
25792578
* def wordwrap(words, maxwidth)
25802579
* # if cols is a local variable, 2nd "each" may start with non-zero cols.
25812580
* words.slice_before(cols: 0) { |w, h|
@@ -2603,8 +2602,8 @@ slicebefore_i(VALUE yielder, VALUE enumerator, int argc, VALUE *argv)
26032602
* # 20
26042603
* # ----------
26052604
*
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.
26082607
*
26092608
* # parse mbox
26102609
* open("mbox") { |f|

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy