Class: MingleEvents::EntryCache::Entries::Enumerator

Inherits:
Object
  • Object
show all
Defined in:
lib/mingle_events/entry_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir, first, last) ⇒ Enumerator

Returns a new instance of Enumerator.



88
89
90
91
92
# File 'lib/mingle_events/entry_cache.rb', line 88

def initialize(dir, first, last)
  @dir, @first, @last = dir, first, last
  @last_pos = :limbo
  @current_pos = first
end

Instance Method Details

#nextObject

Raises:

  • (StopIteration)


94
95
96
97
98
99
100
101
# File 'lib/mingle_events/entry_cache.rb', line 94

def next
  raise StopIteration.new unless has_next?
   = @dir.file(@current_pos) {|f| YAML.load(f) }
  Feed::Entry.from_snippet([:entry_xml]).tap do
    @last_pos = @current_pos
    @current_pos = [:next_entry_file_path]
  end
end