class Conditions::InCondition
Checks if an element (or elements of an array) belong to an array Can be used as an “equals to” condition
Public Class Methods
new(predicate)
click to toggle source
@param [Array] predicate An array predicate
Calls superclass method
Conditions::BaseCondition::new
# File lib/conditions.rb, line 26 def initialize(predicate) raise ConditionError, "In condition value must be an Array, not #{predicate.class}" unless predicate.is_a? Array super(predicate) end
Public Instance Methods
apply(value)
click to toggle source
@param [Any, Array] value A value to be checked against the predicate @return [true] if value and predicate have overlapping values @return [false] if value and predicate have no overlapping values
# File lib/conditions.rb, line 36 def apply(value) value = [value] unless value.is_a? Array (value & @predicate).any? end