Sha256: ddabb8f73c6abd8c366b2d7719e279276f243b142a9c26cd1011d5de4c8bcaed

Contents?: true

Size: 745 Bytes

Versions: 19

Compression:

Stored size: 745 Bytes

Contents

module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module String #:nodoc:
      # Additional string tests.
      module StartsEndsWith
        def self.included(base)
          base.class_eval do
            alias_method :start_with?, :starts_with?
            alias_method :end_with?, :ends_with?
          end
        end

        # 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

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
activesupport-2.0.5 lib/active_support/core_ext/string/starts_ends_with.rb
activesupport-2.0.4 lib/active_support/core_ext/string/starts_ends_with.rb
activesupport-2.0.2 lib/active_support/core_ext/string/starts_ends_with.rb
radiant-0.6.5.1 vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
radiant-0.6.5 vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
radiant-0.6.6 vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
radiant-0.6.7 vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
radiant-0.6.9 vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
radiant-0.6.8 vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
spree-0.0.9 vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
spree-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
swivel-0.0.149 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/starts_ends_with.rb
swivel-0.0.150 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/starts_ends_with.rb
swivel-0.0.175 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/starts_ends_with.rb
swivel-0.0.156 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/starts_ends_with.rb
swivel-0.0.157 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/starts_ends_with.rb
swivel-0.0.152 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/starts_ends_with.rb
swivel-0.0.155 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/starts_ends_with.rb
swivel-0.0.160 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/starts_ends_with.rb