Sha256: 392919e33ff5aea747b7a4335c96fb08ef22fc78d42d6316e5e17386a0e8b9d4

Contents?: true

Size: 474 Bytes

Versions: 1

Compression:

Stored size: 474 Bytes

Contents

class String

  # Searches for the first occurrence of a delimiter, and returns the
  # portion of the string before that.  If the delimiter is not found,
  # returns a copy of the original string.  Equivalent to
  # <code>split(delim, 2)[0]</code> for non-empty delimiters.
  #
  # @param [String] delim delimiter to search for
  # @return [String] portion of the string before the first +delim+
  def before(delim)
    self[0, self.index(delim) || self.length]
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
casual_support-2.0.0 lib/casual_support/string/before.rb