Sha256: 2fe98b3f982de899b27d72a85a998a076efd00dd665d16805595f7fedcd5cb2b

Contents?: true

Size: 654 Bytes

Versions: 30

Compression:

Stored size: 654 Bytes

Contents

unless String.method_defined? :delete_prefix
  require 'backports/tools/arguments'

  class String
    def delete_prefix(prefix)
      prefix = Backports.coerce_to_str(prefix)
      if rindex(prefix, 0)
        self[prefix.length..-1]
      else
        dup
      end
    end
  end
end

unless String.method_defined? :delete_prefix!
  require 'backports/tools/arguments'

  class String
    def delete_prefix!(prefix)
      prefix = Backports.coerce_to_str(prefix)
      chomp! if frozen?
      len = prefix.length
      if len > 0 && rindex(prefix, 0)
        self[0...prefix.length] = ''
        self
      else
        nil
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
backports-3.25.0 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.24.1 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.24.0 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.23.0 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.22.1 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.22.0 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.21.0 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.20.2 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.20.1 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.20.0 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.19.0 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.18.2 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.18.1 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.18.0 lib/backports/2.5.0/string/delete_prefix.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/backports-3.12.0/lib/backports/2.5.0/string/delete_prefix.rb
backports-3.17.2 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.17.1 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.17.0 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.16.1 lib/backports/2.5.0/string/delete_prefix.rb
backports-3.16.0 lib/backports/2.5.0/string/delete_prefix.rb