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.
170
171
172
173
174
175
176
177
|
# File 'lib/level_db.rb', line 170
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
179
180
181
|
# File 'lib/level_db.rb', line 179
def close
@iterator.close
end
|
#each ⇒ Object
194
195
196
197
198
199
200
|
# File 'lib/level_db.rb', line 194
def each
return self unless block_given?
rewind
yield self.next while next?
close
self
end
|
#next ⇒ Object
183
184
185
186
187
|
# File 'lib/level_db.rb', line 183
def next
raise StopIteration unless next?
v, @next = @next, nil
v
end
|
#next? ⇒ Boolean
189
190
191
192
|
# File 'lib/level_db.rb', line 189
def next?
@next = internal_next unless @next
!!@next
end
|
#rewind ⇒ Object
202
203
204
205
206
207
|
# File 'lib/level_db.rb', line 202
def rewind
@next = nil
@started = false
@exhausted = false
@count = 0
end
|