Sha256: 91b224658266c2d121700ef5aeb60b06e53d6c9684996c4ebfd1450cd3400a28

Contents?: true

Size: 778 Bytes

Versions: 47

Compression:

Stored size: 778 Bytes

Contents

unless ("check partition".partition(" ") rescue false)
  require 'backports/tools/alias_method_chain'
  require 'backports/tools/arguments'

  class String
    def partition_with_new_meaning(pattern = Backports::Undefined)
      return partition_without_new_meaning{|c| yield c} if pattern == Backports::Undefined
      pattern = Backports.coerce_to(pattern, String, :to_str) unless pattern.is_a? Regexp
      i = index(pattern)
      return [self, "", ""] unless i
      if pattern.is_a? Regexp
        match = Regexp.last_match
        [match.pre_match, match[0], match.post_match]
      else
        last = i+pattern.length
        [self[0...i], self[i...last], self[last...length]]
      end
    end
    Backports.alias_method_chain self, :partition, :new_meaning
  end
end

Version data entries

47 entries across 47 versions & 4 rubygems

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