diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-11 11:35:26 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-11 11:35:26 -0500 |
commit | 315350847f5089fa2b314b00d485e5121f5622d4 (patch) | |
tree | 09ab2c059c5238cbf60781a62e31792a46743dec /activesupport | |
parent | 7d07666e629e105ca69ee7cefee0130b5c7ac808 (diff) | |
download | rails-315350847f5089fa2b314b00d485e5121f5622d4.tar.gz rails-315350847f5089fa2b314b00d485e5121f5622d4.tar.bz2 rails-315350847f5089fa2b314b00d485e5121f5622d4.zip |
added docs to String#to
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/access.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb index 8a922a7069..5cdf42ce4b 100644 --- a/activesupport/lib/active_support/core_ext/string/access.rb +++ b/activesupport/lib/active_support/core_ext/string/access.rb @@ -34,6 +34,19 @@ class String self[position..-1] end + # Returns the beginning of the string up to position. If the position is + # negative, it is counted from the end of the string. + # + # str = "hello" + # str.to(0) #=> "h" + # str.to(3) #=> "hell" + # str.to(-2) #=> "hell" + # + # You can mix it with +from+ method and do fun things like: + # + # str = "hello" + # str.from(0).to(-1) #=> "hello" + # str.from(1).to(-2) #=> "ell" def to(position) self[0..position] end |