class Evertils::Common::Entity::Notes
Public Instance Methods
all(keyword)
click to toggle source
@since 0.3.2
# File lib/evertils/common/entity/notes.rb, line 7 def all(keyword) find_all(keyword, nil, 1000) end
find_all(title, notebook = nil, limit = 300, include_note_body = false)
click to toggle source
@since 0.2.0
# File lib/evertils/common/entity/notes.rb, line 13 def find_all(title, notebook = nil, limit = 300, include_note_body = false) filters = find_filters(title, notebook) response = @evernote.call(:findNotesMetadata, filters, 0, limit, find_spec(include_note_body)) response.notes end
Also aliased as: find
find_by_date(date, period = :created)
click to toggle source
@since 0.2.9
# File lib/evertils/common/entity/notes.rb, line 71 def find_by_date(date, period = :created) filter = ::Evernote::EDAM::NoteStore::NoteFilter.new filter.words = "#{period}:year-#{year_diff(date.year)}" filter.order = 1 spec = ::Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new spec.includeTitle = true spec.includeUpdated = true spec.includeCreated = true pool = @evernote.call(:findNotesMetadata, filter, 0, 300, spec) pool.notes.select do |note| n = note_date(note, period) n.strftime('%m-%d-%Y') == date.strftime('%m-%d-%Y') end end
find_by_date_range(start, finish = DateTime.now, period = :created)
click to toggle source
@since 0.2.9
# File lib/evertils/common/entity/notes.rb, line 47 def find_by_date_range(start, finish = DateTime.now, period = :created) filter = ::Evernote::EDAM::NoteStore::NoteFilter.new filter.words = "#{period}:year-#{year_diff(start.year)}" filter.order = 1 spec = ::Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new spec.includeTitle = true spec.includeUpdated = true spec.includeCreated = true spec.includeContent = true if include_note_content pool = @evernote.call(:findNotesMetadata, filter, 0, 300, spec) 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 n <= f && n >= s end end
find_by_filter(filter)
click to toggle source
@since 0.3.2
# File lib/evertils/common/entity/notes.rb, line 92 def find_by_filter(filter) spec = ::Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new spec.includeTitle = true spec.includeUpdated = true spec.includeCreated = true @evernote.call(:findNotesMetadata, filter, 0, 300, spec) end
find_by_tag(tag_name)
click to toggle source
@since 0.2.0
# File lib/evertils/common/entity/notes.rb, line 34 def find_by_tag(tag_name) filter = ::Evernote::EDAM::NoteStore::NoteFilter.new filter.words = "tag:#{tag_name}" spec = ::Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new spec.includeTitle = true response = @evernote.call(:findNotesMetadata, filter, nil, 300, spec) response.notes end
find_one(title, notebook = nil, include_note_body = false)
click to toggle source
@since 0.2.0
# File lib/evertils/common/entity/notes.rb, line 23 def find_one(title, notebook = nil, include_note_body = false) filters = find_filters(title, notebook) response = @evernote.call(:findNotesMetadata, filters, 0, 10, find_spec(include_note_body)) notes = response.notes.detect { |note| note.title == title } notes end
Private Instance Methods
find_filters(title, notebook)
click to toggle source
@since 0.3.2
# File lib/evertils/common/entity/notes.rb, line 122 def find_filters(title, notebook) filter = ::Evernote::EDAM::NoteStore::NoteFilter.new filter.words = "intitle:#{title}" if title filter.notebookGuid = notebook if notebook filter end
find_spec(include_note_body)
click to toggle source
@since 0.3.2
# File lib/evertils/common/entity/notes.rb, line 131 def find_spec(include_note_body) spec = ::Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new spec.includeTitle = true spec.includeContentLength = true spec.includeCreated = true spec.includeUpdated = true spec end
note_date(note, period)
click to toggle source
@since 0.2.0
# File lib/evertils/common/entity/notes.rb, line 116 def note_date(note, period) DateTime.strptime(note.send(period).to_s[0...-3], '%s') end
year_diff(start_year)
click to toggle source
@since 0.2.9
# File lib/evertils/common/entity/notes.rb, line 105 def year_diff(start_year) curr_year = DateTime.now.year diff = curr_year - start_year return 1 if diff == 0 || start_year > curr_year diff end