class ENUtils::NoteFilter
Constants
- OrderFields
created: 1, updated: 2, relevance: 3, update_sequence_number: 4, title: 5
Public Class Methods
available_order?(value)
click to toggle source
# File lib/evernote_utils/filter.rb, line 19 def self.available_order?(value) return false if value.nil? OrderFields.keys.include?(value.to_sym) end
build(core, o={})
click to toggle source
# File lib/evernote_utils/filter.rb, line 9 def self.build(core, o={}) filter = Evernote::EDAM::NoteStore::NoteFilter.new filter.notebookGuid = notebook_guid(core, o[:notebook]) if o[:notebook] filter.tagGuids = tag_guids(core, tag: o[:tag], tags: o[:tags]) if o[:tag] || o[:tags] filter.words = o[:words] if o[:words] filter.order = OrderFields[o[:order].to_sym] if available_order?(o[:order]) filter.ascending = o[:asc] if o[:asc] filter end
Private Class Methods
notebook_guid(core, notebook)
click to toggle source
# File lib/evernote_utils/filter.rb, line 26 def self.notebook_guid(core, notebook) if notebook.is_a?(ENUtils::Notebook) notebook.guid elsif ENUtils::GUID_REGEXP =~ notebook notebook else Notebook.find_by_name(core, notebook).try(:guid) end end
tag_guids(core, tag: nil, tags: nil)
click to toggle source
# File lib/evernote_utils/filter.rb, line 36 def self.tag_guids(core, tag: nil, tags: nil) search_tags = (tags || []) + [tag] search_tags.compact.map do |t| if t.is_a?(ENUtils::Tag) t.guid elsif ENUtils::GUID_REGEXP =~ t t else Tag.find_by_name(core, t).try(:guid) end end.compact end