Sha256: e76a76dcccd5eac16b83267fd5e31d2406c79cc46fcdfd2819d35c9425f350eb

Contents?: true

Size: 799 Bytes

Versions: 84

Compression:

Stored size: 799 Bytes

Contents

module Gherkin
  module Formatter
    class Argument
      require 'gherkin/java_impl'
      java_impl('gherkin.jar')

      attr_reader :byte_offset, :val

      def initialize(byte_offset, val)
        @byte_offset, @val = byte_offset, val
      end
      
      def self.format(string, argument_format, arguments)
        s = string.dup
        offset = past_offset = 0
        arguments.each do |arg|
          next if arg.byte_offset.nil? || arg.byte_offset < past_offset
          replacement = argument_format.format_argument(arg.val)
          s[arg.byte_offset + offset, arg.val.length] = replacement
          offset += replacement.unpack("U*").length - arg.val.unpack("U*").length
          past_offset = arg.byte_offset + arg.val.length
        end
        s
      end
    end
  end
end

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
gherkin-1.0.29 lib/gherkin/formatter/argument.rb
gherkin-1.0.29-i386-mswin32 lib/gherkin/formatter/argument.rb
gherkin-1.0.29-i386-mingw32 lib/gherkin/formatter/argument.rb
gherkin-1.0.29-java lib/gherkin/formatter/argument.rb
gherkin-1.0.28 lib/gherkin/formatter/argument.rb
gherkin-1.0.28-i386-mswin32 lib/gherkin/formatter/argument.rb
gherkin-1.0.28-i386-mingw32 lib/gherkin/formatter/argument.rb
gherkin-1.0.28-java lib/gherkin/formatter/argument.rb
gherkin-1.0.27 lib/gherkin/formatter/argument.rb
gherkin-1.0.27-i386-mswin32 lib/gherkin/formatter/argument.rb
gherkin-1.0.27-i386-mingw32 lib/gherkin/formatter/argument.rb
gherkin-1.0.27-java lib/gherkin/formatter/argument.rb
gherkin-1.0.26 lib/gherkin/formatter/argument.rb
gherkin-1.0.26-i386-mswin32 lib/gherkin/formatter/argument.rb
gherkin-1.0.26-i386-mingw32 lib/gherkin/formatter/argument.rb
gherkin-1.0.26-java lib/gherkin/formatter/argument.rb
gherkin-1.0.25 lib/gherkin/formatter/argument.rb
gherkin-1.0.25-i386-mswin32 lib/gherkin/formatter/argument.rb
gherkin-1.0.25-i386-mingw32 lib/gherkin/formatter/argument.rb
gherkin-1.0.25-java lib/gherkin/formatter/argument.rb