Class: Evernotable::Client::Note
Instance Attribute Summary collapse
Attributes inherited from Base
#client_token, #current_user
Instance Method Summary
collapse
Methods included from Utilities
#display, #encrypt_key, #error, #format_with_bang, #output_with_bang, #read_from_file, #wrap_enml, #write_to_file
Constructor Details
#initialize(params = {}) ⇒ Note
Returns a new instance of Note.
8
9
10
11
12
13
14
|
# File 'lib/evernotable/client/note.rb', line 8
def initialize(params={})
super(params)
@api = @config["note_api"][@env]
@notebook_name = @config["notebook"]["name"]
@notebook_guid = nil
@instance = Evernote::NoteStore.new("#{@api}#{params[:user_shard]}")
end
|
Instance Attribute Details
#notebook_guid ⇒ Object
Returns the value of attribute notebook_guid.
6
7
8
|
# File 'lib/evernotable/client/note.rb', line 6
def notebook_guid
@notebook_guid
end
|
Instance Method Details
#add_note(note_text) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/evernotable/client/note.rb', line 22
def add_note(note_text)
self.add_notebook unless notebook_exists?
wrap_method('attempt to create a new note') do |client_token|
@instance.createNote(client_token, Evernote::EDAM::Type::Note.new({:title => note_text, :content => wrap_enml(note_text), :notebookGuid => @notebook_guid}))
end
end
|
#add_notebook ⇒ Object
16
17
18
19
20
|
# File 'lib/evernotable/client/note.rb', line 16
def add_notebook
wrap_method('attempt to create new notebook') do |client_token|
@notebook_guid = @instance.createNotebook(client_token, Evernote::EDAM::Type::Notebook.new({:name => @notebook_name})).guid
end
end
|
#expunge_notebook ⇒ Object
45
46
47
48
49
50
|
# File 'lib/evernotable/client/note.rb', line 45
def expunge_notebook
return unless notebook_exists?
wrap_method('attempt to expunge the evernotable notebook') do |client_token|
@instance.expungeNotebook(client_token, @notebook_guid)
end
end
|
#expunge_trashed_notes ⇒ Object
52
53
54
55
56
|
# File 'lib/evernotable/client/note.rb', line 52
def expunge_trashed_notes
wrap_method('attempt to expunge all trashed notes') do |client_token|
@instance.expungeInactiveNotes(client_token)
end
end
|
#list_notebooks ⇒ Object
41
42
43
|
# File 'lib/evernotable/client/note.rb', line 41
def list_notebooks
wrap_method('attempt to list notebooks') { |client_token| @instance.listNotebooks(client_token) }
end
|
#list_notes ⇒ Object
34
35
36
37
38
39
|
# File 'lib/evernotable/client/note.rb', line 34
def list_notes
return unless notebook_exists?
wrap_method('attempt to list notes') do |client_token|
@instance.findNotes(client_token, Evernote::EDAM::NoteStore::NoteFilter.new({:notebookGuid => @notebookGuid}), 0, 100).notes
end
end
|
#notebook_exists? ⇒ Boolean
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/evernotable/client/note.rb', line 58
def notebook_exists?
notebooks = list_notebooks
notebooks.each do |notebook|
if notebook.name == 'evernotable'
@notebook_guid = notebook.guid
return true
end
end
return false
end
|
#remove_note(note_guid) ⇒ Object
29
30
31
32
|
# File 'lib/evernotable/client/note.rb', line 29
def remove_note(note_guid)
return unless notebook_exists?
wrap_method('attempt to remove a note') { |client_token| @instance.deleteNote(client_token, note_guid) }
end
|