Sha256: 486a6fcc7361f4c54d85fa6ea0e4de075f281c79c59d15722b9309f06af86216

Contents?: true

Size: 721 Bytes

Versions: 26

Compression:

Stored size: 721 Bytes

Contents

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

  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

26 entries across 26 versions & 2 rubygems

Version Path
scout_realtime-1.0.5 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-1.0.4 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-1.0.3 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-1.0.3.pre lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-1.0.2 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-1.0.1 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-1.0.0 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-0.5.5 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-0.5.5.pre lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-0.5.4 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
backports-3.6.0 lib/backports/1.8.7/string/partition.rb
backports-3.5.0 lib/backports/1.8.7/string/partition.rb
backports-3.4.1 lib/backports/1.8.7/string/partition.rb
scout_realtime-0.5.3 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-0.5.2 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
scout_realtime-0.5.1 lib/vendor/backports-3.3.5/lib/backports/1.8.7/string/partition.rb
backports-3.4.0 lib/backports/1.8.7/string/partition.rb
backports-3.3.5 lib/backports/1.8.7/string/partition.rb
backports-3.3.4 lib/backports/1.8.7/string/partition.rb
backports-3.3.3 lib/backports/1.8.7/string/partition.rb