Sha256: 15fba9f865a29bee6988335c69cfb81d0598eb233ded84e0f1f42f14f1f02cd8

Contents?: true

Size: 475 Bytes

Versions: 20

Compression:

Stored size: 475 Bytes

Contents

class String

  # Left chomp.
  #
  #   "help".lchomp("h")  #=> "elp"
  #   "help".lchomp("k")  #=> "help"
  #
  # CREDIT: Trans

  def lchomp(match)
    if index(match) == 0
      self[match.size..-1]
    else
      self.dup
    end
  end

  # In-place left chomp.
  #
  #   "help".lchomp("h")  #=> "elp"
  #   "help".lchomp("k")  #=> "help"
  #
  # CREDIT: Trans

  def lchomp!(match)
    if index(match) == 0
      self[0...match.size] = ''
      self
    end
  end

end

Version data entries

20 entries across 19 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/string/lchomp.rb
facets-3.1.0 lib/core/facets/string/lchomp.rb
facets-3.0.0 lib/core/facets/string/lchomp.rb
facets-2.9.3 lib/core/facets/string/lchomp.rb
facets-2.9.2 src/core/facets/string/lchomp.rb
facets-2.9.2 lib/core/facets/string/lchomp.rb
facets-2.9.1 lib/core/facets/string/lchomp.rb
facets-2.9.0 lib/core/facets/string/lchomp.rb
facets-2.9.0.pre.2 lib/core/facets/string/lchomp.rb
facets-2.9.0.pre.1 lib/core/facets/string/lchomp.rb
facets-2.8.4 lib/core/facets/string/chomp.rb
facets-2.8.3 lib/core/facets/string/chomp.rb
facets-2.8.2 lib/core/facets/string/chomp.rb
facets-2.8.1 lib/core/facets/string/chomp.rb
facets-2.8.0 lib/core/facets/string/chomp.rb
facets-2.7.0 lib/core/facets/string/chomp.rb
facets-2.6.0 lib/core/facets/string/chomp.rb
facets-2.5.1 lib/core/facets/string/chomp.rb
facets-2.5.0 lib/core/facets/string/chomp.rb
facets-2.5.2 lib/core/facets/string/chomp.rb