diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-04-05 03:52:58 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-04-05 03:52:58 +0000 |
commit | aa4af60aad5772458e8ba3bd08505781aeeb53a2 (patch) | |
tree | 22eadb1dc551f95e3150f803dc654eaa125544d9 /activesupport/lib/active_support/core_ext/array | |
parent | 08318b8bcd32bae741e672899a33c6a7d52664c8 (diff) | |
download | rails-aa4af60aad5772458e8ba3bd08505781aeeb53a2.tar.gz rails-aa4af60aad5772458e8ba3bd08505781aeeb53a2.tar.bz2 rails-aa4af60aad5772458e8ba3bd08505781aeeb53a2.zip |
Improve documentation.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9226 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array')
5 files changed, 10 insertions, 20 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/access.rb b/activesupport/lib/active_support/core_ext/array/access.rb index fce319d3c6..21a8584bb9 100644 --- a/activesupport/lib/active_support/core_ext/array/access.rb +++ b/activesupport/lib/active_support/core_ext/array/access.rb @@ -3,9 +3,8 @@ module ActiveSupport #:nodoc: module Array #:nodoc: # Makes it easier to access parts of an array. module Access - # Returns the remaining of the array from the +position+. + # Returns the tail of the array from +position+. # - # Examples: # %w( a b c d ).from(0) # => %w( a b c d ) # %w( a b c d ).from(2) # => %w( c d ) # %w( a b c d ).from(10) # => nil @@ -13,9 +12,8 @@ module ActiveSupport #:nodoc: self[position..-1] end - # Returns the beginning of the array up to the +position+. + # Returns the beginning of the array up to +position+. # - # Examples: # %w( a b c d ).to(0) # => %w( a ) # %w( a b c d ).to(2) # => %w( a b c ) # %w( a b c d ).to(10) # => %w( a b c d ) diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index e46d7c1884..34b1551abc 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -30,10 +30,8 @@ module ActiveSupport #:nodoc: map(&:to_param).join '/' end - # Converts an array into a string suitable for use as a URL query string, using the given <tt>key</tt> as the - # param name. - # - # Example: + # Converts an array into a string suitable for use as a URL query string, + # using the given +key+ as the param name. # # ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding" def to_query(key) @@ -81,8 +79,6 @@ module ActiveSupport #:nodoc: # # Root children have as node name the one of the root singularized. # - # Example: - # # [{:foo => 1, :bar => 2}, {:baz => 3}].to_xml # # <?xml version="1.0" encoding="UTF-8"?> diff --git a/activesupport/lib/active_support/core_ext/array/extract_options.rb b/activesupport/lib/active_support/core_ext/array/extract_options.rb index 980d36400b..eb917576d7 100644 --- a/activesupport/lib/active_support/core_ext/array/extract_options.rb +++ b/activesupport/lib/active_support/core_ext/array/extract_options.rb @@ -2,7 +2,8 @@ module ActiveSupport #:nodoc: module CoreExtensions #:nodoc: module Array #:nodoc: module ExtractOptions - # Extract options from a set of arguments. Removes and returns the last element in the array if it's a hash, otherwise returns a blank hash. + # Extracts options from a set of arguments. Removes and returns the last + # element in the array if it's a hash, otherwise returns a blank hash. # # def options(*args) # args.extract_options! diff --git a/activesupport/lib/active_support/core_ext/array/grouping.rb b/activesupport/lib/active_support/core_ext/array/grouping.rb index ed5ec72daf..767acc4e07 100644 --- a/activesupport/lib/active_support/core_ext/array/grouping.rb +++ b/activesupport/lib/active_support/core_ext/array/grouping.rb @@ -4,11 +4,8 @@ module ActiveSupport #:nodoc: module CoreExtensions #:nodoc: module Array #:nodoc: module Grouping - # Iterate over an array in groups of a certain size, padding any remaining - # slots with specified value (<tt>nil</tt> by default) unless it is - # <tt>false</tt>. - # - # Examples: + # 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) {|g| p g} # ["1", "2", "3"] @@ -42,11 +39,9 @@ module ActiveSupport #:nodoc: end end - # Divide the array into one or more subarrays based on a delimiting +value+ + # Divides the array into one or more subarrays based on a delimiting +value+ # or the result of an optional block. # - # Examples: - # # [1, 2, 3, 4, 5].split(3) # => [[1, 2], [4, 5]] # (1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]] def split(value = nil, &block) diff --git a/activesupport/lib/active_support/core_ext/array/random_access.rb b/activesupport/lib/active_support/core_ext/array/random_access.rb index b7ee00742a..54d17cbf30 100644 --- a/activesupport/lib/active_support/core_ext/array/random_access.rb +++ b/activesupport/lib/active_support/core_ext/array/random_access.rb @@ -2,7 +2,7 @@ module ActiveSupport #:nodoc: module CoreExtensions #:nodoc: module Array #:nodoc: module RandomAccess - # Return a random element from the array. + # Returns a random element from the array. def rand self[Kernel.rand(length)] end |