aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorAlexey Vakhov <vakhov@gmail.com>2012-05-25 16:47:00 +0400
committerAlexey Vakhov <vakhov@gmail.com>2012-05-25 16:47:00 +0400
commitd83411134b3a207b767b1f6759cbe964e0088e27 (patch)
tree28f0666fda42e3d880b40d764c13816cd97fa9e9 /activesupport/lib/active_support/core_ext
parent05ae220d2e3de751486951a88800e98f0c1014fa (diff)
downloadrails-d83411134b3a207b767b1f6759cbe964e0088e27.tar.gz
rails-d83411134b3a207b767b1f6759cbe964e0088e27.tar.bz2
rails-d83411134b3a207b767b1f6759cbe964e0088e27.zip
Update examples of Array #in_groups and #in_groups_of
Examples should be not square to visually underline a difference between Array#in_groups and Array#in_groups_of.
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/array/grouping.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/grouping.rb b/activesupport/lib/active_support/core_ext/array/grouping.rb
index ac1ae53db0..a184eb492a 100644
--- a/activesupport/lib/active_support/core_ext/array/grouping.rb
+++ b/activesupport/lib/active_support/core_ext/array/grouping.rb
@@ -2,18 +2,21 @@ class Array
# Splits or iterates over the array in groups of size +number+,
# padding any remaining slots with +fill_with+ unless it is +false+.
#
- # %w(1 2 3 4 5 6 7).in_groups_of(3) {|group| p group}
+ # %w(1 2 3 4 5 6 7 8 9 10).in_groups_of(3) {|group| p group}
# ["1", "2", "3"]
# ["4", "5", "6"]
- # ["7", nil, nil]
+ # ["7", "8", "9"]
+ # ["10", nil, nil]
#
- # %w(1 2 3).in_groups_of(2, '&nbsp;') {|group| p group}
+ # %w(1 2 3 4 5).in_groups_of(2, '&nbsp;') {|group| p group}
# ["1", "2"]
- # ["3", "&nbsp;"]
+ # ["3", "4"]
+ # ["5", "&nbsp;"]
#
- # %w(1 2 3).in_groups_of(2, false) {|group| p group}
+ # %w(1 2 3 4 5).in_groups_of(2, false) {|group| p group}
# ["1", "2"]
- # ["3"]
+ # ["3", "4"]
+ # ["5"]
def in_groups_of(number, fill_with = nil)
if fill_with == false
collection = self
@@ -42,10 +45,10 @@ class Array
# ["5", "6", "7", nil]
# ["8", "9", "10", nil]
#
- # %w(1 2 3 4 5 6 7).in_groups(3, '&nbsp;') {|group| p group}
- # ["1", "2", "3"]
- # ["4", "5", "&nbsp;"]
- # ["6", "7", "&nbsp;"]
+ # %w(1 2 3 4 5 6 7 8 9 10).in_groups(3, '&nbsp;') {|group| p group}
+ # ["1", "2", "3", "4"]
+ # ["5", "6", "7", "&nbsp;"]
+ # ["8", "9", "10", "&nbsp;"]
#
# %w(1 2 3 4 5 6 7).in_groups(3, false) {|group| p group}
# ["1", "2", "3"]