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.



151
152
153
154
# File 'lib/level_db.rb', line 151

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

Instance Method Details

#each(&block) ⇒ Object



156
157
158
159
160
161
162
163
# File 'lib/level_db.rb', line 156

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