Sha256: edb25ccf0c64d102f9e1415a966cc1dab2b6bdcbc525637c88ac5e00fe44eac8

Contents?: true

Size: 480 Bytes

Versions: 1

Compression:

Stored size: 480 Bytes

Contents

class String

  # Removes the beginning of the string if that portion matches the
  # argument.  Otherwise returns a duplicate of the string.  Like
  # String#chomp, but operates on the left side (beginning) of the
  # string.
  #
  # Also see https://bugs.ruby-lang.org/issues/10574
  #
  # @param [String] head substring to match and remove
  # @return [String] chomped string
  def lchomp(head)
    self.start_with?(head) ? self[head.length, self.length] : self.dup
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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