Sha256: 0784972ed0a7636734d97a1c5dceb06149be57d071b68123d3b03af89a79e13c
Contents?: true
Size: 644 Bytes
Versions: 1
Compression:
Stored size: 644 Bytes
Contents
class String # Searches for the last 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, -1)[0...-1].join(delimiter)</code> for # existent delimiters. # # @example # "/path/to/file".before_last("/") # == "/path/to" # "/path/to/file".before_last(".") # == "/path/to/file" # "/path/to/file".before_last("") # == "/path/to/file" # # @param delimiter [String] # @return [String] def before_last(delimiter) self[0, self.rindex(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_last.rb |