Returns whether the Array contains all of the items.
[1, 2, 3].include_all?(1, 2) #=> true [1, 2, 3].include_all?(1, 4) #=> false [1, 2, 3].include_all?(4, 5) #=> false
# File lib/more_core_extensions/core_ext/array/inclusions.rb, line 29 def include_all?(*items) (items - self).empty? end
Returns whether the Array contains any of the items.
[1, 2, 3].include_any?(1, 2) #=> true [1, 2, 3].include_any?(1, 4) #=> true [1, 2, 3].include_any?(4, 5) #=> false
# File lib/more_core_extensions/core_ext/array/inclusions.rb, line 9 def include_any?(*items) !(self & items).empty? end
Returns whether the Array contains none of the items.
[1, 2, 3].include_none?(1, 2) #=> false [1, 2, 3].include_none?(1, 4) #=> false [1, 2, 3].include_none?(4, 5) #=> true
# File lib/more_core_extensions/core_ext/array/inclusions.rb, line 19 def include_none?(*items) (self & items).empty? end
Returns whether the Array has a value at the index.
[1, 2, 3].includes_index?(-4) #=> false [1, 2, 3].includes_index?(-3) #=> true [1, 2, 3].includes_index?(1) #=> true [1, 2, 3].includes_index?(2) #=> true [1, 2, 3].includes_index?(3) #=> false
# File lib/more_core_extensions/core_ext/array/inclusions.rb, line 41 def includes_index?(index) (-self.length...self.length).cover?(index) end