Sha256: ae90299751147684a9d2a10afc3b3ef9b721f6ac64390bda32fabcc4aa44f03f

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

module Cucumber
  module TagExpressions
    # Literal expression node
    class Literal
      def initialize(value)
        @value = value
      end

      def evaluate(variables)
        variables.include?(@value)
      end

      def to_s
        @value.gsub(/\\/, "\\\\\\\\").gsub(/\(/, "\\(").gsub(/\)/, "\\)")
      end
    end

    # Not expression node
    class Not
      def initialize(expression)
        @expression = expression
      end

      def evaluate(variables)
        !@expression.evaluate(variables)
      end

      def to_s
        "not ( #{@expression} )"
      end
    end

    # Or expression node
    class Or
      def initialize(left, right)
        @left = left
        @right = right
      end

      def evaluate(variables)
        @left.evaluate(variables) || @right.evaluate(variables)
      end

      def to_s
        "( #{@left} or #{@right} )"
      end
    end

    # And expression node
    class And
      def initialize(left, right)
        @left = left
        @right = right
      end

      def evaluate(variables)
        @left.evaluate(variables) && @right.evaluate(variables)
      end

      def to_s
        "( #{@left} and #{@right} )"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-tag-expressions-4.1.0/lib/cucumber/tag_expressions/expressions.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-tag-expressions-4.1.0/lib/cucumber/tag_expressions/expressions.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-tag-expressions-4.1.0/lib/cucumber/tag_expressions/expressions.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-tag-expressions-4.1.0/lib/cucumber/tag_expressions/expressions.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-tag-expressions-4.1.0/lib/cucumber/tag_expressions/expressions.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-tag-expressions-4.1.0/lib/cucumber/tag_expressions/expressions.rb
cucumber-tag-expressions-4.1.0 lib/cucumber/tag_expressions/expressions.rb