Class: Rdayone::EntryList
- Inherits:
-
Object
- Object
- Rdayone::EntryList
- Includes:
- Enumerable
- Defined in:
- lib/rdayone/entry_list.rb
Instance Method Summary collapse
- #each ⇒ Object
- #fetch(index) ⇒ Object (also: #[])
-
#initialize(entry_paths, finder) ⇒ EntryList
constructor
A new instance of EntryList.
- #sort_desc ⇒ Object
Constructor Details
#initialize(entry_paths, finder) ⇒ EntryList
Returns a new instance of EntryList.
7 8 9 10 11 |
# File 'lib/rdayone/entry_list.rb', line 7 def initialize(entry_paths, finder) @entry_paths = entry_paths @entry_cache = {} @finder = finder end |
Instance Method Details
#each ⇒ Object
31 32 33 34 35 |
# File 'lib/rdayone/entry_list.rb', line 31 def each (0..@entry_paths.length - 1).each do |index| yield self.fetch(index) end end |
#fetch(index) ⇒ Object Also known as: []
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rdayone/entry_list.rb', line 13 def fetch(index) raise ArgumentError if index > @entry_paths.length entry = @entry_cache[index] unless entry uuid = @finder.uuid_from_path(@entry_paths[index]) photo = @finder.find_photo_for(uuid) entry = Rdayone::Entry.new(Plist::parse_xml(@entry_paths[index]), photo) @entry_cache[index] = entry end entry end |
#sort_desc ⇒ Object
27 28 29 |
# File 'lib/rdayone/entry_list.rb', line 27 def sort_desc sort { |e1, e2| e2.creation_date <=> e1.creation_date } end |