Module ActiveSupport::CoreExtensions::String::StartsEndsWith
In: vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb

Additional string tests.

Methods

Public Class methods

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb, line 6
 6:         def self.included(base)
 7:           base.class_eval do
 8:             alias_method :start_with?, :starts_with?
 9:             alias_method :end_with?, :ends_with?
10:           end
11:         end

Public Instance methods

Does the string end with the specified suffix?

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb, line 20
20:         def ends_with?(suffix)
21:           suffix = suffix.to_s
22:           self[-suffix.length, suffix.length] == suffix      
23:         end

Does the string start with the specified prefix?

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb, line 14
14:         def starts_with?(prefix)
15:           prefix = prefix.to_s
16:           self[0, prefix.length] == prefix
17:         end

[Validate]