Class: Evertils::Common::Model::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/evertils/common/model/note.rb

Overview

Since:

  • 0.3.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf = {}) ⇒ Note

Returns a new instance of Note.

Since:

  • 0.3.3



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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

Instance Attribute Details

#colourObject

Since:

  • 0.3.0



8
9
10
# File 'lib/evertils/common/model/note.rb', line 8

def colour
  @colour
end

#confObject (readonly)

Since:

  • 0.3.0



9
10
11
# File 'lib/evertils/common/model/note.rb', line 9

def conf
  @conf
end

#shareableObject

Since:

  • 0.3.0



8
9
10
# File 'lib/evertils/common/model/note.rb', line 8

def shareable
  @shareable
end

#updatedObject

Since:

  • 0.3.0



8
9
10
# File 'lib/evertils/common/model/note.rb', line 8

def updated
  @updated
end

Instance Method Details

#bodyObject Also known as: content

Accessor for the body/content property

Since:

  • 0.3.3



51
52
53
# File 'lib/evertils/common/model/note.rb', line 51

def body
  @note.content
end

#createdObject

Accessor for the created_on property

Since:

  • 0.3.3



70
71
72
# File 'lib/evertils/common/model/note.rb', line 70

def created
  @note.created
end

#entityObject

The whole note

Since:

  • 0.3.3



76
77
78
# File 'lib/evertils/common/model/note.rb', line 76

def entity
  @note
end

#notebookObject

Accessor for the notebook property

Since:

  • 0.3.3



58
59
60
# File 'lib/evertils/common/model/note.rb', line 58

def notebook
  @note.notebookGuid
end

#tagsObject

Accessor for the tagNames property

Since:

  • 0.3.3



64
65
66
# File 'lib/evertils/common/model/note.rb', line 64

def tags
  @note.tagNames
end

#titleObject

Accessor for the title property

Since:

  • 0.3.3



45
46
47
# File 'lib/evertils/common/model/note.rb', line 45

def title
  @note.title
end