lib/range_operators/array_operator_definitions.rb
# Returns the values in common for an array set (nil, singe value/object, or range).
Returns the values in common for an array set (nil, singe value/object, or range).
Returns the values in common for an array set ( nil singe value / object or range ) .
def intersection
			array = self.sort_elements
			array.inject() do |common, element|
				value_first = comparison_value(common, :last)
				value_element = comparison_value(element, :first)
				case value_first <=> value_element
				when -1 then return nil
				when 0 then value_first
				else
					if element.class == Range 
						value_element..([value_first, comparison_value(element, :last)].min)
					else
						value_element
					end
				end
			end
		end
def intersection array = self . sort_elements array . inject ( ) do | common , element | value_first = comparison_value ( common , :last ) value_element = comparison_value ( element , :first ) case value_first <=> value_element when - 1 then return nil when 0 then value_first else if element . class == Range value_element .. ( [ value_first , comparison_value ( element , :last ) ] . min ) else value_element end end end end
Returns the values in common for an array set (nil, singe value/object, or range).
Returns the values in common for an array set ( nil singe value / object or range ) .