Class: Rubyzen::Collections::BaseCollection
- Inherits:
-
Array
- Object
- Array
- Rubyzen::Collections::BaseCollection
- Defined in:
- lib/rubyzen/collections/base_collection.rb
Overview
Base collection class for all Rubyzen collections. Extends Array and replaces select/reject with a single filter method that preserves the collection subclass type.
Direct Known Subclasses
AssignmentsCollection, AttributesCollection, BlocksCollection, CallSiteCollection, ClassesCollection, ConstantsCollection, DeclarationCollection, ExpressionsCollection, FileCollection, MacrosCollection, MethodsCollection, ModulesCollection, ParametersCollection, RaisesCollection, RequiresCollection, RescuesCollection, ReturnsCollection
Instance Method Summary collapse
-
#filter {|element| ... } ⇒ BaseCollection, Enumerator
Filters elements by the given block, returning a new collection of the same type.
Instance Method Details
#filter {|element| ... } ⇒ BaseCollection, Enumerator
Filters elements by the given block, returning a new collection of the same type.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubyzen/collections/base_collection.rb', line 19 def filter return enum_for(:filter) unless block_given? result = self.class.new each do |elem| result << elem if yield(elem) end result end |