Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/aerogel/core/core_ext/array.rb
Overview
Core extensions to Array.
Instance Method Summary collapse
-
#contains?(other) ⇒ Boolean
Returns
trueif this array containsothercompletely. -
#except(*args) ⇒ Object
Returns array with excluded elements.
-
#except!(*args) ⇒ Object
Modifies and returns array with excluded elements.
-
#only(*args) ⇒ Object
Returns array containing only elements listed in
args. -
#only!(*args) ⇒ Object
Modifies and returns array containing only elements listed in
args.
Instance Method Details
#contains?(other) ⇒ Boolean
Returns true if this array contains other completely.
33 34 35 |
# File 'lib/aerogel/core/core_ext/array.rb', line 33 def contains?( other ) ( other - self ).blank? end |
#except(*args) ⇒ Object
Returns array with excluded elements.
9 10 11 |
# File 'lib/aerogel/core/core_ext/array.rb', line 9 def except( *args ) self - [ *args ] end |
#except!(*args) ⇒ Object
Modifies and returns array with excluded elements.
15 16 17 |
# File 'lib/aerogel/core/core_ext/array.rb', line 15 def except!( *args ) self.replace( self.except! *args ) end |
#only(*args) ⇒ Object
Returns array containing only elements listed in args.
21 22 23 |
# File 'lib/aerogel/core/core_ext/array.rb', line 21 def only( *args ) self & [*args] end |
#only!(*args) ⇒ Object
Modifies and returns array containing only elements listed in args.
27 28 29 |
# File 'lib/aerogel/core/core_ext/array.rb', line 27 def only!( *args ) self.replace( self.only *args ) end |