Sha256: b8baddbba4a7353f19edb1d1550f9a489eff0a9af0eee49ec29b039c7c57766a

Contents?: true

Size: 378 Bytes

Versions: 1

Compression:

Stored size: 378 Bytes

Contents

class String

  # Prepends a prefix to the string if the string does not already start
  # with that prefix.  Otherwise returns a duplicate of the string.
  # Equivalent to <code>gsub(/^(?!fix)/, "fix")</code>.
  #
  # @param [String] fix prefix to prepend
  # @return [String] prefixed string
  def prefix(fix)
    self.start_with?(fix) ? self.dup : "#{fix}#{self}"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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