class Evertils::Common::Model::Note
Attributes
colour[RW]
conf[R]
updated[RW]
Public Class Methods
new(conf = {})
click to toggle source
@since 0.3.3
# File lib/evertils/common/model/note.rb, line 13 def initialize(conf = {}) @conf = conf raise "Title (title) is a required field" unless conf[:title] @note = ::Evernote::EDAM::Type::Note.new # data which maps directly to the Type::Note object self.colour = conf[:colour] || 0xffffff self.created = conf[:created_on] || DateTime.now note_content = '' note_content += conf[:sections][:header] if valid_header? conf[:sections][:body]&.map { |el| note_content += "<h2>#{el}</h2>" } if valid_body? note_content += conf[:sections][:footer] if valid_footer? self.body = conf[:content] || note_content @note.title = conf[:title] @note.tagNames = conf[:tags] || [] @note.resources = [] # data that must be processed first @notebook = conf[:notebook] || Entity::Notebook.new.default.to_s @resources = conf[:file] || [] @shareable = conf[:share_note] || false @updated = conf[:updated_on] || nil attach_resources attach_notebook end
Public Instance Methods
body()
click to toggle source
Accessor for the body/content property @since 0.3.3
# File lib/evertils/common/model/note.rb, line 51 def body @note.content end
Also aliased as: content
created()
click to toggle source
Accessor for the created_on property @since 0.3.3
# File lib/evertils/common/model/note.rb, line 70 def created @note.created end
entity()
click to toggle source
The whole note @since 0.3.3
# File lib/evertils/common/model/note.rb, line 76 def entity @note end
notebook()
click to toggle source
Accessor for the notebook property @since 0.3.3
# File lib/evertils/common/model/note.rb, line 58 def notebook @note.notebookGuid end
title()
click to toggle source
Accessor for the title property @since 0.3.3
# File lib/evertils/common/model/note.rb, line 45 def title @note.title end
Protected Instance Methods
body=(content)
click to toggle source
Body content must be valid ENML
so we create that here @since 0.3.3
# File lib/evertils/common/model/note.rb, line 84 def body=(content) note_body = ENMLElement.new(colour) note_body.body = content @note.content = note_body.to_s end
created=(date)
click to toggle source
@since 0.3.3
# File lib/evertils/common/model/note.rb, line 93 def created=(date) date ||= Date.now created_on = (date.to_time.to_i * 1000).to_i @note.created = created_on end
Private Instance Methods
attach_notebook()
click to toggle source
# File lib/evertils/common/model/note.rb, line 116 def attach_notebook nb = Manager::Notebook.instance query = nb.find(@notebook.to_s) notebook = query.entity @note.notebookGuid = notebook.guid if query end
attach_resources()
click to toggle source
# File lib/evertils/common/model/note.rb, line 102 def attach_resources if @resources.is_a? Array @resources.each do |f| media_resource = ENML.new(f) content.concat(media_resource.embeddable_element) @note.resources << media_resource.element end else media_resource = ENML.new(@resources) content.concat(media_resource.embeddable_element) @note.resources << media_resource.element end end
valid_body?()
click to toggle source
# File lib/evertils/common/model/note.rb, line 130 def valid_body? sections = conf.key?(:sections) sections && conf[:sections].key?(:header) end
valid_header?()
click to toggle source
# File lib/evertils/common/model/note.rb, line 123 def valid_header? sections = conf.key?(:sections) header = sections && conf[:sections].key?(:header) header && conf[:sections][:header] == 'nil' end