aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array/access.rb
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-28 00:32:17 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-28 00:32:41 -0500
commitb4f0beb68a051495e51dd4a44a08d8a8d53f6998 (patch)
tree6c6a0bbd6d1f1ddc72c3b3ddcda5874a8c9040f1 /activesupport/lib/active_support/core_ext/array/access.rb
parentef498057bbb68d12f930533f455e21aae2056c3e (diff)
downloadrails-b4f0beb68a051495e51dd4a44a08d8a8d53f6998.tar.gz
rails-b4f0beb68a051495e51dd4a44a08d8a8d53f6998.tar.bz2
rails-b4f0beb68a051495e51dd4a44a08d8a8d53f6998.zip
update documentation of array/access methods [ci skip]
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array/access.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/array/access.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/access.rb b/activesupport/lib/active_support/core_ext/array/access.rb
index 44d90ef732..a8f9dddae5 100644
--- a/activesupport/lib/active_support/core_ext/array/access.rb
+++ b/activesupport/lib/active_support/core_ext/array/access.rb
@@ -1,40 +1,48 @@
class Array
# Returns the tail of the array from +position+.
#
- # %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) # => %w()
- # %w().from(0) # => %w()
+ # %w( a b c d ).from(0) # => ["a", "b", "c", "d"]
+ # %w( a b c d ).from(2) # => ["c", "d"]
+ # %w( a b c d ).from(10) # => []
+ # %w().from(0) # => []
def from(position)
self[position, length] || []
end
# Returns the beginning of the array up to +position+.
#
- # %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 )
- # %w().to(0) # => %w()
+ # %w( a b c d ).to(0) # => ["a"]
+ # %w( a b c d ).to(2) # => ["a", "b", "c"]
+ # %w( a b c d ).to(10) # => ["a", "b", "c", "d"]
+ # %w().to(0) # => []
def to(position)
first position + 1
end
# Equal to <tt>self[1]</tt>.
+ #
+ # %w( a b c d e).second # => "b"
def second
self[1]
end
# Equal to <tt>self[2]</tt>.
+ #
+ # %w( a b c d e).third # => "c"
def third
self[2]
end
# Equal to <tt>self[3]</tt>.
+ #
+ # %w( a b c d e).fourth # => "d"
def fourth
self[3]
end
# Equal to <tt>self[4]</tt>.
+ #
+ # %w( a b c d e).fifth # => "e"
def fifth
self[4]
end