Class: Cucumber::Core::Gherkin::TagExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/core/gherkin/tag_expression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_expressions) ⇒ TagExpression

Returns a new instance of TagExpression.



8
9
10
11
12
13
14
# File 'lib/cucumber/core/gherkin/tag_expression.rb', line 8

def initialize(tag_expressions)
  @ands = []
  @limits = {}
  tag_expressions.each do |expr|
    add(expr.strip.split(/\s*,\s*/))
  end
end

Instance Attribute Details

#limitsObject (readonly)

Returns the value of attribute limits.



6
7
8
# File 'lib/cucumber/core/gherkin/tag_expression.rb', line 6

def limits
  @limits
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/cucumber/core/gherkin/tag_expression.rb', line 16

def empty?
  @ands.empty?
end

#evaluate(tags) ⇒ Object



20
21
22
23
24
25
# File 'lib/cucumber/core/gherkin/tag_expression.rb', line 20

def evaluate(tags)
  return true if @ands.flatten.empty?
  vars = Hash[*tags.map{|tag| [tag.name, true]}.flatten]
  raise "No vars" if vars.nil? # Useless statement to prevent ruby warnings about unused var
  !!Kernel.eval(ruby_expression)
end