Class: Cucumber::TagExpressions::Not

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/tag_expressions/expressions.rb

Overview

Not expression node

Instance Method Summary collapse

Constructor Details

#initialize(expression) ⇒ Not

Returns a new instance of Not.



26
27
28
# File 'lib/cucumber/tag_expressions/expressions.rb', line 26

def initialize(expression)
  @expression = expression
end

Instance Method Details

#evaluate(variables) ⇒ Object



30
31
32
# File 'lib/cucumber/tag_expressions/expressions.rb', line 30

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

#to_sObject



34
35
36
37
38
39
40
41
# File 'lib/cucumber/tag_expressions/expressions.rb', line 34

def to_s
  if @expression.is_a?(And) || @expression.is_a?(Or)
    # -- HINT: Binary operations already provide "( ... )"
    "not #{@expression}"
  else
    "not ( #{@expression} )"
  end
end