lib/evertils/common/entity/notes.rb in evertils-common-0.3.0 vs lib/evertils/common/entity/notes.rb in evertils-common-0.3.1

- old
+ new

@@ -12,10 +12,11 @@ spec.includeTitle = true response = @evernote.call(:findNotesMetadata, filter, nil, 300, spec) response.notes end + alias_method :find, :find_all def find_one(title, notebook = nil) filter = ::Evernote::EDAM::NoteStore::NoteFilter.new filter.words = "intitle:#{title}" if title filter.notebookGuid = notebook if notebook @@ -49,19 +50,18 @@ spec.includeTitle = true spec.includeUpdated = true spec.includeCreated = true pool = @evernote.call(:findNotesMetadata, filter, 0, 300, spec) - notes_by_date = [] - pool.notes.each do |note| - note_datetime = note_date(note, period) + notes_by_date = pool.notes.select do |note| + f = finish.to_time.to_i + s = start.to_time.to_i + n = note_date(note, period).to_time.to_i - notes_by_date << note if note_datetime.strftime('%m-%d-%Y') < finish.strftime('%m-%d-%Y') && note_datetime.strftime('%m-%d-%Y') > start.strftime('%m-%d-%Y') + n <= f && n >= s end - - notes_by_date end # # @since 0.2.9 def find_by_date(date, period = :created) @@ -73,18 +73,16 @@ spec.includeTitle = true spec.includeUpdated = true spec.includeCreated = true pool = @evernote.call(:findNotesMetadata, filter, 0, 300, spec) - notes_by_date = [] - pool.notes.each do |note| - note_datetime = note_date(note, period) + notes_by_date = pool.notes.select do |note| + d = date.to_time.to_i + n = note_date(note, period).to_time.to_i - notes_by_date << note if note_datetime.strftime('%m-%d-%Y') == date.strftime('%m-%d-%Y') + n == d end - - notes_by_date end private # \ No newline at end of file