Sha256: d0965b0e15b0d2b386c9eab0a371ec617d3d745ab37500b634a374a3aa04f1f1

Contents?: true

Size: 753 Bytes

Versions: 170

Compression:

Stored size: 753 Bytes

Contents

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

Version data entries

170 entries across 170 versions & 5 rubygems

Version Path
puppet-retrospec-0.12.2 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/in_operator.rb
puppet-3.8.7 lib/puppet/parser/ast/in_operator.rb
puppet-3.8.7-x86-mingw32 lib/puppet/parser/ast/in_operator.rb
puppet-3.8.7-x64-mingw32 lib/puppet/parser/ast/in_operator.rb
puppet-3.8.6 lib/puppet/parser/ast/in_operator.rb
puppet-3.8.6-x86-mingw32 lib/puppet/parser/ast/in_operator.rb
puppet-retrospec-0.12.1 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/in_operator.rb
puppet-3.8.6-x64-mingw32 lib/puppet/parser/ast/in_operator.rb
puppet-retrospec-0.12.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/in_operator.rb
puppet-3.8.5 lib/puppet/parser/ast/in_operator.rb
puppet-3.8.5-x86-mingw32 lib/puppet/parser/ast/in_operator.rb
puppet-3.8.5-x64-mingw32 lib/puppet/parser/ast/in_operator.rb
puppet-3.8.4 lib/puppet/parser/ast/in_operator.rb
puppet-3.8.4-x86-mingw32 lib/puppet/parser/ast/in_operator.rb
puppet-3.8.4-x64-mingw32 lib/puppet/parser/ast/in_operator.rb
puppet-retrospec-0.11.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/in_operator.rb
puppet-retrospec-0.10.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/in_operator.rb
puppet-retrospec-0.9.1 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/in_operator.rb
puppet-retrospec-0.9.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/in_operator.rb
puppet-retrospec-0.8.1 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/in_operator.rb