Sha256: 6559cf87f97389a1041fd257face8db1df220dcd9e8b2367e60fe166fe9f2a1a

Contents?: true

Size: 667 Bytes

Versions: 3

Compression:

Stored size: 667 Bytes

Contents

#
# Core extensions to Array.
#

class Array

  # Returns array with excluded elements.
  #
  def except( *args )
    self - [ *args ]
  end

  # Modifies and returns array with excluded elements.
  #
  def except!( *args )
    self.replace( self.except! *args )
  end

  # Returns array containing only elements listed in +args+.
  #
  def only( *args )
    self & [*args]
  end

  # Modifies and returns array containing only elements listed in +args+.
  #
  def only!( *args )
    self.replace( self.only *args )
  end

  # Returns +true+ if this array contains +other+ completely.
  #
  def contains?( other )
    ( other - self ).blank?
  end


end # class Array

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aerogel-core-1.4.12 lib/aerogel/core/core_ext/array.rb
aerogel-core-1.4.11 lib/aerogel/core/core_ext/array.rb
aerogel-core-1.4.10 lib/aerogel/core/core_ext/array.rb