HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/in_operator.rb
require 'puppet'
require 'puppet/parser/ast/branch'

class Puppet::Parser::AST
  class InOperator < AST::Branch

    attr_accessor :lval, :rval

    # Returns a boolean which is the result of the 'in' operation
    # of lval and rval operands
    def evaluate(scope)

      # evaluate the operands, should return a boolean value
      lval = @lval.safeevaluate(scope)
      raise ArgumentError, "'#{lval}' from left operand of 'in' expression is not a string" unless lval.is_a?(::String)

      rval = @rval.safeevaluate(scope)
      unless rval.respond_to?(:include?)
        raise ArgumentError, "'#{rval}' from right operand of 'in' expression is not of a supported type (string, array or hash)"
      end
      rval.include?(lval)
    end
  end
end