Class: AppEngine::Datastore::Iterator

Inherits:
Object
  • Object
show all
Defined in:
lib/appengine-apis/datastore.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(array) ⇒ Iterator

Returns a new instance of Iterator.



570
571
572
573
574
# File 'lib/appengine-apis/datastore.rb', line 570

def initialize(array)
  @array = array
  @index = 0
  @removed = false
end

Instance Method Details

#hasNextObject



576
577
578
# File 'lib/appengine-apis/datastore.rb', line 576

def hasNext
  @index < @array.size
end

#nextObject



580
581
582
583
584
585
# File 'lib/appengine-apis/datastore.rb', line 580

def next
  raise java.util.NoSuchElementException unless hasNext
  @removed = false
  @index += 1
  @array[@index - 1]
end

#removeObject



587
588
589
590
591
592
# File 'lib/appengine-apis/datastore.rb', line 587

def remove
  raise java.lang.IllegalStateException if @removed
  raise java.lang.IllegalStateException unless @index > 0
  @removed = true
  @array.delete_at(@index - 1)
end