Class: Firuta::Base
- Inherits:
-
Object
- Object
- Firuta::Base
- Defined in:
- lib/firuta.rb
Direct Known Subclasses
Constant Summary collapse
- COMMANDS =
[ [:filter, Commands::Filter], [:map, Commands::Map], [:sort, Commands::Sort], [:reduce, Commands::Reduce], [:paginate, Commands::Paginate], [:uniq, Commands::Uniq], [:find, Commands::Find] ].freeze
Instance Method Summary collapse
- #apply(collection = nil) ⇒ Object
-
#initialize(collection = nil) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(collection = nil) ⇒ Base
Returns a new instance of Base.
16 17 18 19 20 |
# File 'lib/firuta.rb', line 16 def initialize(collection = nil) @commands = [] @collection = collection @terminal_command_added = false end |
Instance Method Details
#apply(collection = nil) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/firuta.rb', line 42 def apply(collection = nil) result = collection || @collection @commands.each do |command| result = command.apply_to(result) end result end |