Class: Nozbe::Note
- Inherits:
-
Object
- Object
- Nozbe::Note
- Defined in:
- lib/nozbe/note.rb
Overview
Note class
-
It is associated with a Project and a Context
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#body_show ⇒ Object
Returns the value of attribute body_show.
-
#context ⇒ Object
Returns the value of attribute context.
-
#date ⇒ Object
Returns the value of attribute date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#project ⇒ Object
Returns the value of attribute project.
Class Method Summary collapse
-
.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.
-
.list_for_context(user_key, context_id) ⇒ Object
List all notes for the given Context (using its ID).
-
.list_for_project(user_key, project_id) ⇒ Object
List all notes for the given Project (using its ID).
Instance Method Summary collapse
-
#save!(user_key) ⇒ Object
Save the current Note instance - used to create a new note, not to save an already existing but modified note.
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/nozbe/note.rb', line 5 def body @body end |
#body_show ⇒ Object
Returns the value of attribute body_show.
5 6 7 |
# File 'lib/nozbe/note.rb', line 5 def body_show @body_show end |
#context ⇒ Object
Returns the value of attribute context.
5 6 7 |
# File 'lib/nozbe/note.rb', line 5 def context @context end |
#date ⇒ Object
Returns the value of attribute date.
5 6 7 |
# File 'lib/nozbe/note.rb', line 5 def date @date end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/nozbe/note.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/nozbe/note.rb', line 5 def name @name end |
#project ⇒ Object
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 |