Class: Log4ever::Notebook
- Inherits:
-
Object
- Object
- Log4ever::Notebook
- Defined in:
- lib/log4r/evernote.rb
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.
-
#guid ⇒ Object
notebook guid.
-
#initialize(auth_store) ⇒ Notebook
constructor
constructor.
Constructor Details
#initialize(auth_store) ⇒ Notebook
constructor
61 62 63 |
# File 'lib/log4r/evernote.rb', line 61 def initialize(auth_store) @auth_store = auth_store end |
Instance Method Details
#clear ⇒ Object
clear notebook object
104 105 106 107 |
# File 'lib/log4r/evernote.rb', line 104 def clear @notebooks = @auth_store.note_store.listNotebooks(@auth_store.auth_token) @notebook = nil end |
#create(notebook_name, stack_name = nil) ⇒ Object
create notebook
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/log4r/evernote.rb', line 86 def create(notebook_name, stack_name = nil) notebook = ::Evernote::EDAM::Type::Notebook.new notebook.name = notebook_name notebook.stack = stack_name begin @notebook = @auth_store.note_store.createNotebook(@auth_store.auth_token, notebook) Log4r::Logger.log_internal { "Create notebook: #{stack_name}/#{notebook_name}" } @notebook rescue => e Log4r::Logger.log_internal { e. } raise EvernoteError, "Create notebook failed. Probably, already exists notebook of same name.", caller if @notebook.nil? end end |
#get(notebook_name, stack_name = nil) ⇒ Object
get notebook
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/log4r/evernote.rb', line 66 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 = @auth_store.note_store.listNotebooks(@auth_store.auth_token) if @notebooks.nil? @notebook = nil @notebook_name = notebook_name @stack_name = stack_name @notebooks.each do |notebook| 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 @notebook || create(notebook_name, stack_name) end |
#guid ⇒ Object
notebook guid
101 |
# File 'lib/log4r/evernote.rb', line 101 def guid; @notebook.guid end |