Sha256: 16863b44cce411d90a73f30e8d12fb8ad2b63da2389d4c5353a631811d203da3

Contents?: true

Size: 836 Bytes

Versions: 3

Compression:

Stored size: 836 Bytes

Contents

require 'cucumber/cucumber_expressions/group'

module Cucumber
  module CucumberExpressions
    class GroupBuilder
      def initialize
        @group_builders = []
        @capturing = true
      end

      def add(group_builder)
        @group_builders.push(group_builder)
      end

      def build(match, group_indices)
        group_index = group_indices.next
        children = @group_builders.map {|gb| gb.build(match, group_indices)}
        Group.new(match[group_index], match.offset(group_index)[0], match.offset(group_index)[1], children)
      end

      def set_non_capturing!
        @capturing = false
      end

      def capturing?
        @capturing
      end

      def move_children_to(group_builder)
        @group_builders.each do |child|
          group_builder.add(child)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cucumber-expressions-4.0.3 lib/cucumber/cucumber_expressions/group_builder.rb
cucumber-expressions-4.0.2 lib/cucumber/cucumber_expressions/group_builder.rb
cucumber-expressions-4.0.1 lib/cucumber/cucumber_expressions/group_builder.rb