Sha256: 447c8e4afd521ee0e4dd33e4bb111edcef6ef46413d1f0d358f2e442aed52e83
Contents?: true
Size: 573 Bytes
Versions: 11
Compression:
Stored size: 573 Bytes
Contents
unless String.method_defined? :remove_suffix class String # Removes a suffix in a string. # # @return [String] a new string without the suffix. # # @example # 'Ladies Night'.remove_suffix(' Night') #=> 'Ladies' def remove_suffix(pattern) dup.remove_suffix!(pattern) end # Removes a suffix in a string. # # @return [String] the string without the suffix. # # @example # 'Ladies Night'.remove_suffix!(' Night') #=> 'Ladies' def remove_suffix!(pattern) gsub!(/#{pattern}\z/, '') end end end
Version data entries
11 entries across 11 versions & 3 rubygems