Class: Evernote::EDAM::Type::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/evernote/edam/type/note.rb

Instance Method Summary collapse

Instance Method Details

#add_resource(filename, file, mime) ⇒ String

Add resource to this note.

Parameters:

  • filename (String)

    the name of the resource

  • file (File)
  • mime (String)

    MIME type of the resource

Returns:

  • (String)

    Hexdigest of the given file



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/evernote/edam/type/note.rb', line 27

def add_resource(filename, file, mime)
  hash_func = Digest::MD5.new

  data = Evernote::EDAM::Type::Data.new
  data.size = file.size
  data.bodyHash = hash_func.digest(file)
  data.body = file

  resource = Evernote::EDAM::Type::Resource.new
  resource.mime = mime
  resource.data = data
  resource.attributes = Evernote::EDAM::Type::ResourceAttributes.new
  resource.attributes.fileName = filename

  self.resources = [] unless self.resources
  self.resources << resource

  hash_func.hexdigest(file)
end

#notebookEvernote::EDAM::Type::Notebook

Returns the notebook that contains this note.



9
10
11
# File 'lib/evernote/edam/type/note.rb', line 9

def notebook
  @notebook ||= note_store.getNotebook(notebookGuid)
end

#tagsArray<Evernote::EDAM::Type::Tag>

Returns the tags that are applied to this note.

Returns:



16
17
18
# File 'lib/evernote/edam/type/note.rb', line 16

def tags
  @tags ||= (tagGuids || []).map{|guid| note_store.getTag(guid)}
end