From ed116eda053e8cccb5dda1c4724f8609eceaa90f Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Fri, 11 May 2012 13:11:06 -0500 Subject: added docs to String#last --- activesupport/lib/active_support/core_ext/string/access.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb index baa5b84db6..76b30b4c19 100644 --- a/activesupport/lib/active_support/core_ext/string/access.rb +++ b/activesupport/lib/active_support/core_ext/string/access.rb @@ -84,6 +84,16 @@ class String end end + # Returns the last character of the string. If a limit is supplied, returns a substring + # from the end of the string until it reaches the limit value (counting backwards). If + # the given limit is greater than or equal to the string length, returns self. + # + # str = "hello" + # str.last #=> "h" + # str.last(1) #=> "h" + # str.last(2) #=> "lo" + # str.last(0) #=> "" + # str.last(6) #=> "hello" def last(limit = 1) if limit == 0 '' -- cgit v1.2.3