Sha256: f7fb61a97e034568822a81107de93d4bb4cb9492b825725defc39c9f41bbd1fd

Contents?: true

Size: 479 Bytes

Versions: 7

Compression:

Stored size: 479 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

7 entries across 7 versions & 2 rubygems

Version Path
facets-2.4.0 lib/facets/string/chomp.rb
facets-2.4.1 lib/facets/string/chomp.rb
facets-2.4.2 lib/core/facets/string/chomp.rb
facets-2.4.3 lib/core/facets/string/chomp.rb
facets-2.4.4 lib/core/facets/string/chomp.rb
facets-2.4.5 lib/core/facets/string/chomp.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/string/chomp.rb