diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-09 09:09:07 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-09 09:09:07 +0000 |
commit | 7a4a12aeaa2627008a478059aeec5ea38648c19e (patch) | |
tree | 202c4861723f897c0595b058151e1b5881fbf88f /activesupport/lib | |
parent | 17ef7067c86be4e01ac8320ade4f2787c9d7aa57 (diff) | |
download | rails-7a4a12aeaa2627008a478059aeec5ea38648c19e.tar.gz rails-7a4a12aeaa2627008a478059aeec5ea38648c19e.tar.bz2 rails-7a4a12aeaa2627008a478059aeec5ea38648c19e.zip |
Forgot to add core_ext/string/starts_ends_with.rb
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2176 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/starts_ends_with.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb new file mode 100644 index 0000000000..67174019db --- /dev/null +++ b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb @@ -0,0 +1,20 @@ +module ActiveSupport #:nodoc: + module CoreExtensions #:nodoc: + module String #:nodoc: + # Additional string tests. + module StartsEndsWith + # Does the string start with the specified +prefix+? + def starts_with?(prefix) + prefix = prefix.to_s + self[0, prefix.length] == prefix + end + + # Does the string end with the specified +suffix+? + def ends_with?(suffix) + suffix = suffix.to_s + self[-suffix.length, suffix.length] == suffix + end + end + end + end +end |