Class: String

Inherits:
Object show all
Defined in:
lib/core_ext/string.rb

Overview

Extends Ruby’s own String class with method #start_with? for Ruby < 1.8.7

Since:

  • 0.3.0

Instance Method Summary collapse

Instance Method Details

#start_with?(start) ⇒ Boolean

Returns true if this string starts with the given substring

Parameters:

  • start (String)

    The substring to check

Returns:

  • (Boolean)

    true if this String starts with the given substring

Since:

  • 0.3.0



18
19
20
# File 'lib/core_ext/string.rb', line 18

def start_with?(start)
  !/^#{start}/.match(self).nil?
end