Sha256: 7519aec75bb4311c36b77db7469881bcd3b533b6d15fd1b1e07b5369dfc20a47

Contents?: true

Size: 656 Bytes

Versions: 15

Compression:

Stored size: 656 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) || Cucumber::RUBY_1_9
    # Workaround for http://tinyurl.com/55uu3u 
    alias jlength length
  else
    require 'jcode'
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
aslakhellesoy-cucumber-0.1.14.1 lib/cucumber/core_ext/string.rb
aslakhellesoy-cucumber-0.1.14.2 lib/cucumber/core_ext/string.rb
aslakhellesoy-cucumber-0.1.15 lib/cucumber/core_ext/string.rb
aslakhellesoy-cucumber-0.1.16.1 lib/cucumber/core_ext/string.rb
aslakhellesoy-cucumber-0.1.16.2 lib/cucumber/core_ext/string.rb
aslakhellesoy-cucumber-0.1.16.3 lib/cucumber/core_ext/string.rb
aslakhellesoy-cucumber-0.1.16.4 lib/cucumber/core_ext/string.rb
aslakhellesoy-cucumber-0.1.16 lib/cucumber/core_ext/string.rb
kosmas58-cucumber-0.1.16.5 lib/cucumber/core_ext/string.rb
kosmas58-cucumber-0.1.16.6 lib/cucumber/core_ext/string.rb
cucumber-0.1.14 lib/cucumber/core_ext/string.rb
cucumber-0.1.15 lib/cucumber/core_ext/string.rb
cucumber-0.1.16 lib/cucumber/core_ext/string.rb
mack-0.8.3.1 lib/gems/cucumber-0.1.15/lib/cucumber/core_ext/string.rb
mack-0.8.3 lib/gems/cucumber-0.1.15/lib/cucumber/core_ext/string.rb