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

Returns a new instance of 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

Returns:

  • (Boolean)


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

def empty?
  @ands.empty?
end

#eval(tags) ⇒ Object



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

def eval(tags)
  return true if @ands.flatten.empty?
  vars = Hash[*tags.map{|tag| [tag, true]}.flatten]
  !!Kernel.eval(ruby_expression)
end