Class: Puppet::Parser::AST::MatchOperator
- Defined in:
- lib/puppet/parser/ast/match_operator.rb
Instance Attribute Summary collapse
Attributes inherited from Branch
Instance Method Summary collapse
-
#each ⇒ Object
Iterate across all of our children.
-
#evaluate(scope) ⇒ Object
Returns a boolean which is the result of the boolean operation of lval and rval operands.
-
#initialize(hash) ⇒ MatchOperator
constructor
A new instance of MatchOperator.
Constructor Details
#initialize(hash) ⇒ MatchOperator
Returns a new instance of MatchOperator.
22 23 24 25 26 |
# File 'lib/puppet/parser/ast/match_operator.rb', line 22 def initialize(hash) super raise ArgumentError, "Invalid regexp operator #{@operator}" unless %w{!~ =~}.include?(@operator) end |
Instance Attribute Details
#operator ⇒ Object
7 8 9 |
# File 'lib/puppet/parser/ast/match_operator.rb', line 7 def operator @operator end |
Instance Method Details
#each ⇒ Object
Iterate across all of our children.
10 11 12 |
# File 'lib/puppet/parser/ast/match_operator.rb', line 10 def each [@lval,@rval].each { |child| yield child } end |
#evaluate(scope) ⇒ Object
Returns a boolean which is the result of the boolean operation of lval and rval operands
16 17 18 19 20 |
# File 'lib/puppet/parser/ast/match_operator.rb', line 16 def evaluate(scope) lval = @lval.safeevaluate(scope) return(rval.evaluate_match(lval, scope) ? @operator == "=~" : @operator == "!~") end |