Class: LevelDb::LazySelect

Inherits:
Object
  • Object
show all
Includes:
LazyEnumerable
Defined in:
lib/level_db.rb

Instance Method Summary collapse

Methods included from LazyEnumerable

#map, #select

Constructor Details

#initialize(enum, &filter) ⇒ LazySelect

Returns a new instance of LazySelect.



187
188
189
190
# File 'lib/level_db.rb', line 187

def initialize(enum, &filter)
  @enum = enum
  @filter = filter
end

Instance Method Details

#each(&block) ⇒ Object



192
193
194
195
196
197
198
199
# File 'lib/level_db.rb', line 192

def each(&block)
  if block
    @enum.each do |element|
      block.call(element) if @filter.call(element)
    end
  end
  self
end