Permalink
Browse files

added docs to String#from

  • Loading branch information...
1 parent 0822dc0 commit 07045fa919b4787d8ec458a1594f62cdedaf1b06 Francesco Rodriguez committed May 11, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 activesupport/lib/active_support/core_ext/string/access.rb
@@ -30,6 +30,19 @@ def at(position)
self[position]
end
+ # Returns a substring from the given position to the end of the string.
+ # If the position is negative, it is counted from the end of the string.
+ #
+ # str = "hello"
+ # str.from(0) #=> "hello"
+ # str.from(3) #=> "lo"
+ # str.from(-2) #=> "lo"
+ #
+ # You can mix it with +to+ method and do fun things like:
+ #
+ # str = "hello"
+ # str.from(0).to(-1) #=> "hello"
+ # str.from(1).to(-2) #=> "ell"
def from(position)
self[position..-1]
end

0 comments on commit 07045fa

Please sign in to comment.