mirror of
https://github.com/github/rails.git
synced 2026-01-25 22:38:33 -05:00
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
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user