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
AttributesCollection, BlocksCollection, CallSiteCollection, ClassesCollection, ConstantsCollection, DeclarationCollection, FileCollection, MacrosCollection, MethodsCollection, ModulesCollection, ParametersCollection, RaisesCollection, RequiresCollection, RescuesCollection
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.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubyzen/collections/base_collection.rb', line 18 def filter return enum_for(:filter) unless block_given? result = self.class.new each do |elem| result << elem if yield(elem) end result end |