Class: Gherkin::TagExpression

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_expressions) ⇒ TagExpression



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

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



7
8
9
# File 'lib/gherkin/tag_expression.rb', line 7

def limits
  @limits
end

Instance Method Details

#empty?Boolean



17
18
19
# File 'lib/gherkin/tag_expression.rb', line 17

def empty?
  @ands.empty?
end

#evaluate(tags) ⇒ Object



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

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