Class: Nozbe::Context
- Inherits:
-
Object
- Object
- Nozbe::Context
- Defined in:
- lib/nozbe/context.rb
Overview
Context class
-
In Nozbe, a context is used to group Action (or Note) together
-
Some pre-defined contexts are already set
-
The number of user-specific contexts is limited by the Nozbe-account
Constant Summary collapse
- DEFAULT_CONTEXT_NAME =
"No context"
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#body_show ⇒ Object
Returns the value of attribute body_show.
-
#count ⇒ Object
Returns the value of attribute count.
-
#icon ⇒ Object
Returns the value of attribute icon.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.get_default_context(user_key) ⇒ Object
return the default Context instance : the context with its name set to DEFAULT_CONTEXT_NAME.
-
.get_from_name(user_key, context_name) ⇒ Object
return a Context instance from the given context_name - it may return nil if there is no matches WARNING : the Nozbe-API doesn’t provide such a method, so we load all contexts and compare the names with the given name - the comparison is case-insensitive (use ‘downcase’ on all names).
-
.list(user_key) ⇒ Object
List all contexts.
Instance Method Summary collapse
-
#get_actions(user_key, showdone = false) ⇒ Object
List all actions associated with the current context - you can specify if you want to retrieve the already-done actions.
-
#get_notes(user_key) ⇒ Object
List all notes associated with the current context.
-
#load_info(user_key) ⇒ Object
load more infos (body) for the current context.
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
9 10 11 |
# File 'lib/nozbe/context.rb', line 9 def body @body end |
#body_show ⇒ Object
Returns the value of attribute body_show.
9 10 11 |
# File 'lib/nozbe/context.rb', line 9 def body_show @body_show end |
#count ⇒ Object
Returns the value of attribute count.
9 10 11 |
# File 'lib/nozbe/context.rb', line 9 def count @count end |
#icon ⇒ Object
Returns the value of attribute icon.
9 10 11 |
# File 'lib/nozbe/context.rb', line 9 def icon @icon end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/nozbe/context.rb', line 9 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/nozbe/context.rb', line 9 def name @name end |
Class Method Details
.get_default_context(user_key) ⇒ Object
return the default Context instance : the context with its name set to DEFAULT_CONTEXT_NAME
13 14 15 |
# File 'lib/nozbe/context.rb', line 13 def self.get_default_context(user_key) get_from_name(user_key, DEFAULT_CONTEXT_NAME) end |
.get_from_name(user_key, context_name) ⇒ Object
return a Context instance from the given context_name
-
it may return nil if there is no matches
WARNING : the Nozbe-API doesn’t provide such a method, so we load all contexts and compare the names with the given name
-
the comparison is case-insensitive (use ‘downcase’ on all names)
23 24 25 26 27 28 |
# File 'lib/nozbe/context.rb', line 23 def self.get_from_name(user_key, context_name) return nil if context_name.nil? contexts = list(user_key) selected_contexts = contexts.select { |c| c.name.downcase == context_name.downcase } selected_contexts.first rescue nil end |
.list(user_key) ⇒ Object
List all contexts
31 32 33 |
# File 'lib/nozbe/context.rb', line 31 def self.list(user_key) ContextsListApiCall.new(user_key).call end |
Instance Method Details
#get_actions(user_key, showdone = false) ⇒ Object
List all actions associated with the current context
-
you can specify if you want to retrieve the already-done actions
42 43 44 45 46 47 |
# File 'lib/nozbe/context.rb', line 42 def get_actions(user_key, showdone = false) Nozbe::Action.list_for_context(user_key, id, showdone).collect { |action| action.context = self action } end |
#get_notes(user_key) ⇒ Object
List all notes associated with the current context
50 51 52 53 54 55 |
# File 'lib/nozbe/context.rb', line 50 def get_notes(user_key) Nozbe::Note.list_for_context(user_key, id).collect { |note| note.context = self note } end |
#load_info(user_key) ⇒ Object
load more infos (body) for the current context
36 37 38 |
# File 'lib/nozbe/context.rb', line 36 def load_info(user_key) ContextInfoApiCall.new(user_key, self).call end |