Class: Unidata::SelectList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/unidata/select_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(uniselect_list, should_cache = false) ⇒ SelectList

Returns a new instance of SelectList.



5
6
7
8
9
10
# File 'lib/unidata/select_list.rb', line 5

def initialize(uniselect_list, should_cache=false)
  @uniselect_list = uniselect_list
  @should_cache = should_cache
  @cache = []
  @exhausted = false
end

Instance Method Details

#each(&block) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/unidata/select_list.rb', line 12

def each &block
  return [] if @exhausted && !@should_cache
  if @exhausted
    @cache.each &block
  else
    iterate &block
  end
end