Class: Enumerable::Permeator
- Defined in:
- lib/core/facets/enumerable/per.rb
Overview
Permeator is a Functor for operating over each element of an Enumearble. (Note: This used to be called an Elementor.)
TODO: With Ruby 1.9+ this would not be required, as it can be replaced by a generic Functor, becuase then lambda definitions can pass blocks.
Instance Method Summary collapse
-
#initialize(enum_object, enum_method = nil, *enum_args) ⇒ Permeator
constructor
A new instance of Permeator.
- #instance_delegate ⇒ Object
- #instance_operator ⇒ Object
- #method_missing(sym, *args, &blk) ⇒ Object
Constructor Details
#initialize(enum_object, enum_method = nil, *enum_args) ⇒ Permeator
Returns a new instance of Permeator.
38 39 40 41 42 |
# File 'lib/core/facets/enumerable/per.rb', line 38 def initialize(enum_object, enum_method=nil, *enum_args) @enum_object = enum_object @enum_method = enum_method || :map @enum_args = enum_args end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &blk) ⇒ Object
52 53 54 |
# File 'lib/core/facets/enumerable/per.rb', line 52 def method_missing(sym, *args, &blk) @enum_object.__send__(@enum_method){ |x| x.__send__(sym, *args, &blk) } end |