Class: Cucumber::TagExpression
Instance Attribute Summary collapse
-
#limits ⇒ Object
readonly
Returns the value of attribute limits.
Class Method Summary collapse
Instance Method Summary collapse
- #add(tags) ⇒ Object
- #eval(tags) ⇒ Object
-
#initialize ⇒ TagExpression
constructor
A new instance of TagExpression.
Constructor Details
#initialize ⇒ TagExpression
Returns a new instance of TagExpression.
9 10 11 12 |
# File 'lib/cucumber/tag_expression.rb', line 9 def initialize @ands = [] @limits = {} end |
Instance Attribute Details
#limits ⇒ Object (readonly)
Returns the value of attribute limits.
3 4 5 |
# File 'lib/cucumber/tag_expression.rb', line 3 def limits @limits end |
Class Method Details
.parse(tag_expressions) ⇒ Object
5 6 7 |
# File 'lib/cucumber/tag_expression.rb', line 5 def self.parse(tag_expressions) tag_expressions.inject(TagExpression.new) { |e, expr| e.add(expr.strip.split(/\s*,\s*/)); e } end |
Instance Method Details
#add(tags) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/cucumber/tag_expression.rb', line 14 def add() negatives, positives = .partition{|tag| tag =~ /^~/} positive_limits = Hash[*positives.map{|positive| tag, limit = positive.split(':'); [tag, limit ? limit.to_i : nil]}.flatten] @limits.merge!(positive_limits) @ands << (negatives + positive_limits.keys) end |
#eval(tags) ⇒ Object
21 22 23 24 25 |
# File 'lib/cucumber/tag_expression.rb', line 21 def eval() return true if @ands.flatten.empty? vars = Hash[*.map{|tag| [tag, true]}.flatten] !!Kernel.eval(ruby_expression) end |