Sha256: d1d1ecdc82e041061334afb4e7b5e67590796e230c89041b1122d8366617f842

Contents?: true

Size: 632 Bytes

Versions: 8

Compression:

Stored size: 632 Bytes

Contents

class String
  def gzub(regexp, format=nil, &proc)
    md = match(regexp)
    raise "#{self.inspect} doesn't match #{regexp.inspect}" if md.nil?
    
    s = dup
    pos = 0
    md.captures.each_with_index do |m, n|
      replacement = if block_given?
        proc.call(m)
      else
        format % m
      end
      
      if md.offset(n+1)[0]
        s[md.offset(n+1)[0] + pos, m.length] = replacement
        pos += replacement.length - m.length
      end
    end
    s
  end

  if $CUCUMBER_JRUBY && $CUCUMBER_RAILS
    # Workaround for http://tinyurl.com/55uu3u 
    alias jlength length
  else
    require 'jcode'
  end
end

Version data entries

8 entries across 8 versions & 4 rubygems

Version Path
aslakhellesoy-cucumber-0.1.11 lib/cucumber/core_ext/string.rb
aslakhellesoy-cucumber-0.1.12 lib/cucumber/core_ext/string.rb
bts-cucumber-0.1.13.1 lib/cucumber/core_ext/string.rb
bts-cucumber-0.1.13.2 lib/cucumber/core_ext/string.rb
bts-cucumber-0.1.13.3 lib/cucumber/core_ext/string.rb
jeffrafter-cucumber-0.1.12 lib/cucumber/core_ext/string.rb
cucumber-0.1.11 lib/cucumber/core_ext/string.rb
cucumber-0.1.12 lib/cucumber/core_ext/string.rb