Class: Audrey::Query::Q0::Iterator

Inherits:
Object
  • Object
show all
Defined in:
lib/audrey/query/q0.rb

Overview

Audrey::Query::Q0::Iterator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(q0, eiterator) ⇒ Iterator


initialize



327
328
329
330
331
332
333
# File 'lib/audrey/query/q0.rb', line 327

def initialize(q0, eiterator)
	@pk = Audrey::Util.randstr
	@q0 = q0
	@db = @q0.db
	@eiterator = eiterator
	@q0.db.closers[@pk] = self
end

Instance Attribute Details

#eiteratorObject (readonly)

Returns the value of attribute eiterator.



322
323
324
# File 'lib/audrey/query/q0.rb', line 322

def eiterator
  @eiterator
end

#pkObject (readonly)

Returns the value of attribute pk.



321
322
323
# File 'lib/audrey/query/q0.rb', line 321

def pk
  @pk
end

Instance Method Details

#closeObject


close



363
364
365
366
# File 'lib/audrey/query/q0.rb', line 363

def close
	@eiterator.close
	@q0.db.closers.delete(@pk)
end

#nextObject


next



342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/audrey/query/q0.rb', line 342

def next
	# $tm.hrm
	
	# if we get a next record
	if row = @eiterator.next
		return @db.object_from_pk(row['pk'])
	
	# else close
	else
		close()
		return nil
	end
end