Class: ENUtils::Notebook

Inherits:
Evernote::EDAM::Type::Notebook
  • Object
show all
Defined in:
lib/evernote_utils/notebook.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(core, edam_notebook) ⇒ Notebook

Returns a new instance of Notebook.



15
16
17
18
19
20
21
22
23
24
# File 'lib/evernote_utils/notebook.rb', line 15

def initialize(core, edam_notebook)
  @core              = core
  @guid              = edam_notebook.guid
  @name              = edam_notebook.name
  @updateSequenceNum = edam_notebook.updateSequenceNum
  @defaultNotebook   = edam_notebook.defaultNotebook
  @serviceCreated    = Time.at(edam_notebook.serviceCreated/1000)
  @serviceUpdated    = Time.at(edam_notebook.serviceUpdated/1000)
  @restrictions      = edam_notebook.restrictions
end

Instance Attribute Details

#defaultNotebookObject (readonly)

Evernote::EDAM::Type::Notebook fields

guid:"afa4ba59-xxxx-42ed-xxxx-zzzzzzzzzzzz"
name:"Books"
updateSequenceNum:24108
defaultNotebook:false
serviceCreated:1297607548000
serviceUpdated:1387262389000
restrictions:<Evernote::EDAM::Type::NotebookRestrictions ...>


13
14
15
# File 'lib/evernote_utils/notebook.rb', line 13

def defaultNotebook
  @defaultNotebook
end

#guidObject (readonly)

Evernote::EDAM::Type::Notebook fields

guid:"afa4ba59-xxxx-42ed-xxxx-zzzzzzzzzzzz"
name:"Books"
updateSequenceNum:24108
defaultNotebook:false
serviceCreated:1297607548000
serviceUpdated:1387262389000
restrictions:<Evernote::EDAM::Type::NotebookRestrictions ...>


13
14
15
# File 'lib/evernote_utils/notebook.rb', line 13

def guid
  @guid
end

#nameObject (readonly)

Evernote::EDAM::Type::Notebook fields

guid:"afa4ba59-xxxx-42ed-xxxx-zzzzzzzzzzzz"
name:"Books"
updateSequenceNum:24108
defaultNotebook:false
serviceCreated:1297607548000
serviceUpdated:1387262389000
restrictions:<Evernote::EDAM::Type::NotebookRestrictions ...>


13
14
15
# File 'lib/evernote_utils/notebook.rb', line 13

def name
  @name
end

#restrictionsObject (readonly)

Evernote::EDAM::Type::Notebook fields

guid:"afa4ba59-xxxx-42ed-xxxx-zzzzzzzzzzzz"
name:"Books"
updateSequenceNum:24108
defaultNotebook:false
serviceCreated:1297607548000
serviceUpdated:1387262389000
restrictions:<Evernote::EDAM::Type::NotebookRestrictions ...>


13
14
15
# File 'lib/evernote_utils/notebook.rb', line 13

def restrictions
  @restrictions
end

#serviceCreatedObject (readonly)

Evernote::EDAM::Type::Notebook fields

guid:"afa4ba59-xxxx-42ed-xxxx-zzzzzzzzzzzz"
name:"Books"
updateSequenceNum:24108
defaultNotebook:false
serviceCreated:1297607548000
serviceUpdated:1387262389000
restrictions:<Evernote::EDAM::Type::NotebookRestrictions ...>


13
14
15
# File 'lib/evernote_utils/notebook.rb', line 13

def serviceCreated
  @serviceCreated
end

#serviceUpdatedObject (readonly)

Evernote::EDAM::Type::Notebook fields

guid:"afa4ba59-xxxx-42ed-xxxx-zzzzzzzzzzzz"
name:"Books"
updateSequenceNum:24108
defaultNotebook:false
serviceCreated:1297607548000
serviceUpdated:1387262389000
restrictions:<Evernote::EDAM::Type::NotebookRestrictions ...>


13
14
15
# File 'lib/evernote_utils/notebook.rb', line 13

def serviceUpdated
  @serviceUpdated
end

#updateSequenceNumObject (readonly)

Evernote::EDAM::Type::Notebook fields

guid:"afa4ba59-xxxx-42ed-xxxx-zzzzzzzzzzzz"
name:"Books"
updateSequenceNum:24108
defaultNotebook:false
serviceCreated:1297607548000
serviceUpdated:1387262389000
restrictions:<Evernote::EDAM::Type::NotebookRestrictions ...>


13
14
15
# File 'lib/evernote_utils/notebook.rb', line 13

def updateSequenceNum
  @updateSequenceNum
end

Class Method Details

.find_by_guid(core, guid) ⇒ Object



30
31
32
33
# File 'lib/evernote_utils/notebook.rb', line 30

def self.find_by_guid(core, guid)
  notebook = core.notestore.listNotebooks(core.token).find{|nb| nb.guid == guid }
  notebook.present? ? new(core, notebook) : nil
end

.find_by_name(core, name) ⇒ Object



35
36
37
38
# File 'lib/evernote_utils/notebook.rb', line 35

def self.find_by_name(core, name)
  notebook = core.notestore.listNotebooks(core.token).find{|nb| nb.name.downcase == name.to_s.downcase }
  notebook.present? ? new(core, notebook) : nil
end

.where(core, options = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/evernote_utils/notebook.rb', line 40

def self.where(core, options={})
  notebooks = core.notestore.listNotebooks(core.token).map{|nb| new(core, nb) }
  return notebooks if options.empty?
  case options[:name]
  when String
    notebooks.select{|nb| options[:name].downcase == nb.name.downcase }
  when Regexp
    notebooks.select{|nb| options[:name] =~ nb.name }
  else
    notebooks
  end
end

Instance Method Details

#notes(options = {}) ⇒ Object



26
27
28
# File 'lib/evernote_utils/notebook.rb', line 26

def notes(options={})
  Note.where(@core, options.merge(notebook: self))
end