diff options
author | Xavier Noria <fxn@hashref.com> | 2009-11-09 21:35:43 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2009-11-09 22:16:51 +0100 |
commit | c0bb4c6ed2f5a5676569746e7bfd70405346ef8f (patch) | |
tree | 000167d186734157c6b299caf369d00818db1e4f | |
parent | 004db18cb0f690486336f0fa141ad383c79f9558 (diff) | |
download | rails-c0bb4c6ed2f5a5676569746e7bfd70405346ef8f.tar.gz rails-c0bb4c6ed2f5a5676569746e7bfd70405346ef8f.tar.bz2 rails-c0bb4c6ed2f5a5676569746e7bfd70405346ef8f.zip |
String#start_with? and String#end_with? are not needed for Ruby >= 1.8.7, leaves their plural aliases though
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/starts_ends_with.rb | 14 | ||||
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 8 |
2 files changed, 0 insertions, 22 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 index f65bb8f75b..641acf62d0 100644 --- a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +++ b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb @@ -1,18 +1,4 @@ class String - unless '1.8.7 and up'.respond_to?(:start_with?) - # Does the string start with the specified +prefix+? - def start_with?(prefix) - prefix = prefix.to_s - self[0, prefix.length] == prefix - end - - # Does the string end with the specified +suffix+? - def end_with?(suffix) - suffix = suffix.to_s - self[-suffix.length, suffix.length] == suffix - end - end - alias_method :starts_with?, :start_with? alias_method :ends_with?, :end_with? end diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 0f988e78a4..dd9e9e0ebb 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -185,17 +185,9 @@ class StringInflectionsTest < Test::Unit::TestCase assert s.starts_with?('hel') assert !s.starts_with?('el') - assert s.start_with?('h') - assert s.start_with?('hel') - assert !s.start_with?('el') - assert s.ends_with?('o') assert s.ends_with?('lo') assert !s.ends_with?('el') - - assert s.end_with?('o') - assert s.end_with?('lo') - assert !s.end_with?('el') end def test_string_squish |