Module: CowProxy::Enumerable
- Defined in:
- lib/cow_proxy/enumerable.rb
Overview
A mixin to add mutable methods for keep_if, delete_if, select! and reject! to wrap block params with CowProxy
Instance Method Summary collapse
-
#delete_if {|item| ... } ⇒ CowProxy::Array, Enumerator
Deletes every element of self for which block evaluates to true.
-
#keep_if {|item| ... } ⇒ CowProxy::Array, Enumerator
Invokes the given block passing in successive elements from self, deleting elements for which the block returns a false value.
-
#reject! {|item| ... } ⇒ CowProxy::Array, ...
Deletes every element of self for which block evaluates to true.
-
#select! {|item| ... } ⇒ CowProxy::Array, ...
Invokes the given block passing in successive elements from self, deleting elements for which the block returns a false value.
Instance Method Details
#delete_if {|item| ... } ⇒ CowProxy::Array, Enumerator
Deletes every element of self for which block evaluates to true.
37 38 39 |
# File 'lib/cow_proxy/enumerable.rb', line 37 def delete_if(&block) mutable_selector(:reject, &block) end |
#keep_if {|item| ... } ⇒ CowProxy::Array, Enumerator
Invokes the given block passing in successive elements from self, deleting elements for which the block returns a false value.
13 14 15 |
# File 'lib/cow_proxy/enumerable.rb', line 13 def keep_if(&block) mutable_selector(:select, &block) end |
#reject! {|item| ... } ⇒ CowProxy::Array, ...
Deletes every element of self for which block evaluates to true.
49 50 51 |
# File 'lib/cow_proxy/enumerable.rb', line 49 def reject!(&block) mutable_selector!(:delete_if, &block) end |
#select! {|item| ... } ⇒ CowProxy::Array, ...
Invokes the given block passing in successive elements from self, deleting elements for which the block returns a false value.
26 27 28 |
# File 'lib/cow_proxy/enumerable.rb', line 26 def select!(&block) mutable_selector!(:keep_if, &block) end |