Class: Foodcritic::Gherkin::TagExpression
- Inherits:
-
Object
- Object
- Foodcritic::Gherkin::TagExpression
- Defined in:
- lib/foodcritic/gerkin/tag_expression.rb
Instance Attribute Summary collapse
-
#limits ⇒ Object
readonly
Returns the value of attribute limits.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #evaluate(tags) ⇒ Object
-
#initialize(tag_expressions) ⇒ TagExpression
constructor
A new instance of TagExpression.
Constructor Details
#initialize(tag_expressions) ⇒ TagExpression
Returns a new instance of TagExpression.
11 12 13 14 15 16 17 |
# File 'lib/foodcritic/gerkin/tag_expression.rb', line 11 def initialize(tag_expressions) @ands = [] @limits = {} tag_expressions.each do |expr| add(expr.strip.split(/\s*,\s*/)) end end |
Instance Attribute Details
#limits ⇒ Object (readonly)
Returns the value of attribute limits.
9 10 11 |
# File 'lib/foodcritic/gerkin/tag_expression.rb', line 9 def limits @limits end |
Instance Method Details
#empty? ⇒ Boolean
19 20 21 |
# File 'lib/foodcritic/gerkin/tag_expression.rb', line 19 def empty? @ands.empty? end |
#evaluate(tags) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/foodcritic/gerkin/tag_expression.rb', line 23 def evaluate() return true if @ands.flatten.empty? vars = Hash[*.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 |