Class: LevelDb::Cursor
Instance Method Summary
collapse
#map, #select
Methods included from Encoding
#decode_key, #decode_value, #encode_key, #encode_value
Constructor Details
#initialize(iterator, options = {}) ⇒ Cursor
Returns a new instance of Cursor.
206
207
208
209
210
211
212
213
|
# File 'lib/level_db.rb', line 206
def initialize(iterator, options={})
@iterator = iterator
@from = options[:from]
@to = options[:to]
@reverse = options[:reverse]
@limit = options[:limit]
rewind
end
|
Instance Method Details
#close ⇒ Object
215
216
217
|
# File 'lib/level_db.rb', line 215
def close
@iterator.close
end
|
#each ⇒ Object
230
231
232
233
234
235
236
|
# File 'lib/level_db.rb', line 230
def each
return self unless block_given?
rewind
yield self.next while next?
close
self
end
|
#next ⇒ Object
219
220
221
222
223
|
# File 'lib/level_db.rb', line 219
def next
raise StopIteration unless next?
v, @next = @next, nil
v
end
|
#next? ⇒ Boolean
225
226
227
228
|
# File 'lib/level_db.rb', line 225
def next?
@next = internal_next unless @next
!!@next
end
|
#rewind ⇒ Object
238
239
240
241
242
243
|
# File 'lib/level_db.rb', line 238
def rewind
@next = nil
@started = false
@exhausted = false
@count = 0
end
|