Class: Log4ever::Notebook
Instance Method Summary collapse
-
#clear ⇒ Object
clear notebook object.
-
#create(notebook_name, stack_name = nil) ⇒ Object
create notebook.
-
#get(notebook_name, stack_name = nil) ⇒ Object
get notebook.
-
#get!(notebook_name, stack_name = nil) ⇒ Object
get newest notebook.
-
#guid ⇒ Object
notebook guid.
-
#initialize ⇒ Notebook
constructor
A new instance of Notebook.
Methods inherited from Evernote
#note, #notebook, #tag, #to_ascii
Constructor Details
#initialize ⇒ Notebook
Returns a new instance of Notebook.
49 |
# File 'lib/log4r/evernote.rb', line 49 def initialize; end |
Instance Method Details
#clear ⇒ Object
clear notebook object
99 100 101 102 |
# File 'lib/log4r/evernote.rb', line 99 def clear @notebooks = @@note_store.listNotebooks(@@auth_token) @notebook = nil end |
#create(notebook_name, stack_name = nil) ⇒ Object
create notebook
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/log4r/evernote.rb', line 81 def create(notebook_name, stack_name = nil) notebook = ::Evernote::EDAM::Type::Notebook.new notebook.name = notebook_name notebook.stack = stack_name begin @notebook = @@note_store.createNotebook(@@auth_token, notebook) Log4r::Logger.log_internal { "Create notebook: #{stack_name}/#{notebook_name}" } @notebook rescue => e Log4r::Logger.log_internal { e. } nil end end |
#get(notebook_name, stack_name = nil) ⇒ Object
get notebook
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/log4r/evernote.rb', line 52 def get(notebook_name, stack_name = nil) # return cache if same notebook and stack return @notebook if @notebook_name == notebook_name && @stack_name == stack_name # get notebook list from evernote @notebooks = @@note_store.listNotebooks(@@auth_token) if @notebooks.nil? @notebook = nil @notebook_name = notebook_name @stack_name = stack_name @notebooks.each do |notebook| notebook_name = to_ascii(notebook_name) stack_name = to_ascii(stack_name) if notebook.name == notebook_name && notebook.stack == stack_name Log4r::Logger.log_internal { "Get notebook: #{stack_name}/#{notebook_name}" } @notebook = notebook break end end # create new notebook if notebook is nil create(notebook_name, stack_name) if @notebook.nil? @notebook end |
#get!(notebook_name, stack_name = nil) ⇒ Object
get newest notebook
75 76 77 78 |
# File 'lib/log4r/evernote.rb', line 75 def get!(notebook_name, stack_name = nil) clear get(notebook_name, stack_name) end |
#guid ⇒ Object
notebook guid
96 |
# File 'lib/log4r/evernote.rb', line 96 def guid; @notebook.guid end |