Class: QueueIt::ComparisonOperatorHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/queueit_knownuserv3/integration_config_helpers.rb

Class Method Summary collapse

Class Method Details

.contains(value, valueToCompare, isNegative, ignoreCase) ⇒ Object



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/queueit_knownuserv3/integration_config_helpers.rb', line 243

def self.contains(value, valueToCompare, isNegative, ignoreCase)
	if(valueToCompare.eql? "*")
		return true
	end

	if(ignoreCase)
		value = value.upcase
		valueToCompare = valueToCompare.upcase
	end

	evaluation = value.include? valueToCompare
	if(isNegative)
		return !evaluation
	else
		return evaluation
	end
end

.containsAny(value, valuesToCompare, isNegative, ignoreCase) ⇒ Object



313
314
315
316
317
318
319
320
# File 'lib/queueit_knownuserv3/integration_config_helpers.rb', line 313

def self.containsAny(value, valuesToCompare, isNegative, ignoreCase)
	valuesToCompare.each do |valueToCompare|
		if (ComparisonOperatorHelper.contains(value, valueToCompare, false, ignoreCase))
			return !isNegative
		end
	end
	return isNegative
end

.endsWith(value, valueToCompare, isNegative, ignoreCase) ⇒ Object



275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/queueit_knownuserv3/integration_config_helpers.rb', line 275

def self.endsWith(value, valueToCompare, isNegative, ignoreCase)
	if(ignoreCase)
		evaluation = value.upcase.end_with? valueToCompare.upcase
	else
		evaluation = value.end_with? valueToCompare
	end

	if(isNegative)
		return !evaluation
	else
		return evaluation
	end
end

.equals(value, valueToCompare, isNegative, ignoreCase) ⇒ Object



229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/queueit_knownuserv3/integration_config_helpers.rb', line 229

def self.equals(value, valueToCompare, isNegative, ignoreCase)
	if(ignoreCase)
		evaluation = value.upcase.eql? valueToCompare.upcase
	else
		evaluation = value.eql? valueToCompare
	end

	if(isNegative)
		return !evaluation
	else
		return evaluation
	end
end

.equalsAny(value, valuesToCompare, isNegative, ignoreCase) ⇒ Object



304
305
306
307
308
309
310
311
# File 'lib/queueit_knownuserv3/integration_config_helpers.rb', line 304

def self.equalsAny(value, valuesToCompare, isNegative, ignoreCase)
	valuesToCompare.each do |valueToCompare|
		if (ComparisonOperatorHelper.equals(value, valueToCompare, false, ignoreCase))
			return !isNegative
		end
	end
	return isNegative
end

.evaluate(opt, isNegative, ignoreCase, value, valueToCompare, valuesToCompare) ⇒ Object



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/queueit_knownuserv3/integration_config_helpers.rb', line 196

def self.evaluate(opt, isNegative, ignoreCase, value, valueToCompare, valuesToCompare)
	if (value.nil?)
		value = ''
	end
	
	if (valueToCompare.nil?) 
		valueToCompare = ''
	end
	
	if (valuesToCompare.nil?)
		valuesToCompare = []
	end

	case opt		
		when "Equals"
			return ComparisonOperatorHelper.equals(value, valueToCompare, isNegative, ignoreCase)
		when "Contains" 
			return ComparisonOperatorHelper.contains(value, valueToCompare, isNegative, ignoreCase)
		when "StartsWith"
			return ComparisonOperatorHelper.startsWith(value, valueToCompare, isNegative, ignoreCase)
		when "EndsWith"
			return ComparisonOperatorHelper.endsWith(value, valueToCompare, isNegative, ignoreCase)
		when "MatchesWith"
			return ComparisonOperatorHelper.matchesWith(value, valueToCompare, isNegative, ignoreCase)
		when "EqualsAny"
			return ComparisonOperatorHelper.equalsAny(value, valuesToCompare, isNegative, ignoreCase)
		when "ContainsAny"
			return ComparisonOperatorHelper.containsAny(value, valuesToCompare, isNegative, ignoreCase)
		else
			return false
	end
end

.matchesWith(value, valueToCompare, isNegative, ignoreCase) ⇒ Object



289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/queueit_knownuserv3/integration_config_helpers.rb', line 289

def self.matchesWith(value, valueToCompare, isNegative, ignoreCase)
	if(ignoreCase)
		pattern = Regexp.new(valueToCompare, Regexp::IGNORECASE) 
	else
		pattern = Regexp.new(valueToCompare)
	end

	evaluation = pattern.match(value) != nil
	if(isNegative)
		return !evaluation
	else
		return evaluation
	end
end

.startsWith(value, valueToCompare, isNegative, ignoreCase) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/queueit_knownuserv3/integration_config_helpers.rb', line 261

def self.startsWith(value, valueToCompare, isNegative, ignoreCase)
	if(ignoreCase)
		evaluation = value.upcase.start_with? valueToCompare.upcase
	else
		evaluation = value.start_with? valueToCompare
	end

	if(isNegative)
		return !evaluation
	else
		return evaluation
	end
end