Sha256: db49866f9923e45969c6630a54a5a9e8fcabecb7302663d218b4e829d59cf09b

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 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(delimiter, 2)[0]</code> for non-empty delimiters.
  #
  # @example
  #  "http://www.example.com".before("://")  # == "http"
  #  "http://www.example.com".before("?")    # == "http://www.example.com"
  #  "http://www.example.com".before("")     # == ""
  #
  # @param delimiter [String]
  # @return [String]
  def before(delimiter)
    self[0, self.index(delimiter) || self.length]
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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