Class: Nozbe::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/nozbe/note.rb

Overview

Note class

  • It is associated with a Project and a Context

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/nozbe/note.rb', line 5

def body
  @body
end

#body_showObject

Returns the value of attribute body_show.



5
6
7
# File 'lib/nozbe/note.rb', line 5

def body_show
  @body_show
end

#contextObject

Returns the value of attribute context.



5
6
7
# File 'lib/nozbe/note.rb', line 5

def context
  @context
end

#dateObject

Returns the value of attribute date.



5
6
7
# File 'lib/nozbe/note.rb', line 5

def date
  @date
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/nozbe/note.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/nozbe/note.rb', line 5

def name
  @name
end

#projectObject

Returns the value of attribute project.



5
6
7
# File 'lib/nozbe/note.rb', line 5

def project
  @project
end

Class Method Details

.list(user_key) ⇒ Object

List all notes WARNING ! The Nozbe-API doesn’t provide such a method, so we use multiple API calls :

  • load all projects

  • then, for each project, load all notes



12
13
14
15
16
# File 'lib/nozbe/note.rb', line 12

def self.list(user_key)
  Nozbe::Project.list(user_key).inject([]) { |all_notes, project|
    all_notes + project.get_notes(user_key)
  }
end

.list_for_context(user_key, context_id) ⇒ Object

List all notes for the given Context (using its ID)



24
25
26
# File 'lib/nozbe/note.rb', line 24

def self.list_for_context(user_key, context_id)
  NotesListApiCall.new(user_key, {:what => :context, :id => context_id}).call
end

.list_for_project(user_key, project_id) ⇒ Object

List all notes for the given Project (using its ID)



19
20
21
# File 'lib/nozbe/note.rb', line 19

def self.list_for_project(user_key, project_id)
  NotesListApiCall.new(user_key, {:what => :project, :id => project_id}).call
end

Instance Method Details

#save!(user_key) ⇒ Object

Save the current Note instance

  • used to create a new note, not to save an already existing but modified note.

  • return the instance, with its new ID set



31
32
33
# File 'lib/nozbe/note.rb', line 31

def save!(user_key)
  NoteNewApiCall.new(user_key, self).call
end