class Log4ever::Note
Public Class Methods
new(notebook, auth_store)
click to toggle source
# File lib/log4r/evernote.rb, line 110 def initialize(notebook, auth_store) return unless @params.nil? || @params.empty? @params = {} if !notebook.kind_of? ::Evernote::EDAM::Type::Notebook raise EvernoteError, "Expected kind of Notebook, got #{notebook.class}", caller elsif !notebook.respond_to? 'guid' raise NoMethodError, "#{notebook.class} do not has method: guid", caller end @notebook = notebook @auth_store = auth_store end
Public Instance Methods
addContent(text)
click to toggle source
append content
# File lib/log4r/evernote.rb, line 146 def addContent(text) new_html = "<div style='font-family: Courier New'>" + text + "</div>" content_xml.at('en-note').inner_html += new_html @params[:content] = @content_ = content_xml.to_xml end
clear()
click to toggle source
clear
# File lib/log4r/evernote.rb, line 229 def clear @note = @content_ = @content_xml = nil end
content()
click to toggle source
get note content text
# File lib/log4r/evernote.rb, line 161 def content return @content_ unless @content_.nil? @note.nil? and get @content_ = !@note.nil? && !@note.guid.nil? ? @auth_store.note_store.getNoteContent(@auth_store.auth_token, @note.guid) : "" end
content=(text)
click to toggle source
set new content
# File lib/log4r/evernote.rb, line 153 def content=(text) @params[:content] = @content_ = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n" + "<en-note style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\">\n" + "<div style=\"font-family: Courier New\">" + text + "</div></en-note>" end
content_xml()
click to toggle source
get note content xml object
# File lib/log4r/evernote.rb, line 168 def content_xml return @content_xml unless @content_xml.nil? @content_xml = Nokogiri::XML(content) end
create()
click to toggle source
create note
# File lib/log4r/evernote.rb, line 174 def create @auth_store.note_store.createNote(@auth_store.auth_token, createNote) end
createNote()
click to toggle source
create note object
# File lib/log4r/evernote.rb, line 207 def createNote @note = ::Evernote::EDAM::Type::Note.new @note.notebookGuid = @notebook.guid @params.each{|method, value| @note.send("#{method.to_s}=", value)} @note end
created_at()
click to toggle source
get created time
# File lib/log4r/evernote.rb, line 222 def created_at time = get.created.to_s ut = time.slice(0, time.length - 3) Time.at(ut.to_f) end
get()
click to toggle source
get latest note object
# File lib/log4r/evernote.rb, line 184 def get return @note unless @note.nil? filter = ::Evernote::EDAM::NoteStore::NoteFilter.new filter.order = ::Evernote::EDAM::Type::NoteSortOrder::CREATED filter.notebookGuid = @notebook.guid filter.timeZone = "Asia/Tokyo" filter.ascending = false # descending note_list = @auth_store.note_store.findNotes(@auth_store.auth_token, filter, 0, 1) if note_list.notes.empty? Log4r::Logger.log_internal { "Note not found at #{@notebook.guid}" } @note = ::Evernote::EDAM::Type::Note.new else @note = note_list.notes[0] end @note end
get!()
click to toggle source
force get latest note object
# File lib/log4r/evernote.rb, line 202 def get! clear and get end
guid()
click to toggle source
note guid
# File lib/log4r/evernote.rb, line 128 def guid; @note.guid end
size()
click to toggle source
content size
# File lib/log4r/evernote.rb, line 123 def size content.bytesize end
title=(str)
click to toggle source
set new title
# File lib/log4r/evernote.rb, line 131 def title=(str) @params[:title] = str end
update()
click to toggle source
update note
# File lib/log4r/evernote.rb, line 179 def update @auth_store.note_store.updateNote(@auth_store.auth_token, updateNote) end
updateNote()
click to toggle source
get note object
# File lib/log4r/evernote.rb, line 215 def updateNote @note.nil? and get @note.content = @params[:content] @note end