Class: Nozbe::Action
- Inherits:
-
Object
- Object
- Nozbe::Action
- Defined in:
- lib/nozbe/action.rb
Overview
Action class
-
In Nozbe, an action is a todo task.
-
It can be ‘done’ or not, or be your ‘next’ action or not.
-
It is associated with a Project and a Context
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#done ⇒ Object
Returns the value of attribute done.
-
#done_time ⇒ Object
Returns the value of attribute done_time.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_show ⇒ Object
Returns the value of attribute name_show.
-
#next ⇒ Object
Returns the value of attribute next.
-
#project ⇒ Object
Returns the value of attribute project.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
-
.done!(user_key, actions = []) ⇒ Object
Mark all given Action instances as ‘done’ - return true or false.
-
.list(user_key, showdone = false) ⇒ Object
List all actions - you can specify if you want to retrieve the already-done actions 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 actions.
-
.list_for_context(user_key, context_id, showdone = false) ⇒ Object
List all actions for the given Context (using its ID) - you can specify if you want to retrieve the already-done actions.
-
.list_for_project(user_key, project_id, showdone = false) ⇒ Object
List all actions for the given Project (using its ID) - you can specify if you want to retrieve the already-done actions.
-
.list_next(user_key) ⇒ Object
List all ‘next’ actions.
Instance Method Summary collapse
-
#done!(user_key) ⇒ Object
Mark the current Action instance as ‘done’ - return true or false.
-
#save!(user_key) ⇒ Object
Save the current Action instance - used to create a new action, not to save an already existing but modified action.
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
7 8 9 |
# File 'lib/nozbe/action.rb', line 7 def context @context end |
#done ⇒ Object
Returns the value of attribute done.
7 8 9 |
# File 'lib/nozbe/action.rb', line 7 def done @done end |
#done_time ⇒ Object
Returns the value of attribute done_time.
7 8 9 |
# File 'lib/nozbe/action.rb', line 7 def done_time @done_time end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/nozbe/action.rb', line 7 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/nozbe/action.rb', line 7 def name @name end |
#name_show ⇒ Object
Returns the value of attribute name_show.
7 8 9 |
# File 'lib/nozbe/action.rb', line 7 def name_show @name_show end |
#next ⇒ Object
Returns the value of attribute next.
7 8 9 |
# File 'lib/nozbe/action.rb', line 7 def next @next end |
#project ⇒ Object
Returns the value of attribute project.
7 8 9 |
# File 'lib/nozbe/action.rb', line 7 def project @project end |
#time ⇒ Object
Returns the value of attribute time.
7 8 9 |
# File 'lib/nozbe/action.rb', line 7 def time @time end |
Class Method Details
.done!(user_key, actions = []) ⇒ Object
Mark all given Action instances as ‘done’
-
return true or false
44 45 46 47 |
# File 'lib/nozbe/action.rb', line 44 def self.done!(user_key, actions = []) return false if actions.empty? ActionCheckApiCall.new(user_key, actions.collect{|action|action.id}).call end |
.list(user_key, showdone = false) ⇒ Object
List all actions
-
you can specify if you want to retrieve the already-done actions
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 actions
15 16 17 18 19 |
# File 'lib/nozbe/action.rb', line 15 def self.list(user_key, showdone = false) Nozbe::Project.list(user_key).inject([]) { |all_actions, project| all_actions + project.get_actions(user_key, showdone) } end |
.list_for_context(user_key, context_id, showdone = false) ⇒ Object
List all actions for the given Context (using its ID)
-
you can specify if you want to retrieve the already-done actions
36 37 38 39 40 |
# File 'lib/nozbe/action.rb', line 36 def self.list_for_context(user_key, context_id, showdone = false) params = {:what => :context, :id => context_id} params[:showdone] = "1" if showdone ActionsListApiCall.new(user_key, params).call end |
.list_for_project(user_key, project_id, showdone = false) ⇒ Object
List all actions for the given Project (using its ID)
-
you can specify if you want to retrieve the already-done actions
28 29 30 31 32 |
# File 'lib/nozbe/action.rb', line 28 def self.list_for_project(user_key, project_id, showdone = false) params = {:what => :project, :id => project_id} params[:showdone] = "1" if showdone ActionsListApiCall.new(user_key, params).call end |
.list_next(user_key) ⇒ Object
List all ‘next’ actions
22 23 24 |
# File 'lib/nozbe/action.rb', line 22 def self.list_next(user_key) ActionsListApiCall.new(user_key, {:what => :next}).call end |
Instance Method Details
#done!(user_key) ⇒ Object
Mark the current Action instance as ‘done’
-
return true or false
51 52 53 |
# File 'lib/nozbe/action.rb', line 51 def done!(user_key) self.class.done!(user_key, [self]) end |
#save!(user_key) ⇒ Object
Save the current Action instance
-
used to create a new action, not to save an already existing but modified action.
-
return the instance, with its new ID set
58 59 60 |
# File 'lib/nozbe/action.rb', line 58 def save!(user_key) ActionNewApiCall.new(user_key, self).call end |