Class: MilkCap::RTM::Task
- Inherits:
-
MilkResource
- Object
- MilkResource
- MilkCap::RTM::Task
- Includes:
- DataNormalization
- Defined in:
- lib/milk_cap/rtm/resources.rb
Overview
The RTM Task class.
Instance Attribute Summary collapse
-
#list_id ⇒ Object
readonly
Returns the value of attribute list_id.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#task_id ⇒ Object
readonly
Returns the value of attribute task_id.
-
#taskseries_id ⇒ Object
readonly
Returns the value of attribute taskseries_id.
Class Method Summary collapse
-
.add!(name, opts = {}) ⇒ Object
Adds a new task (and returns it).
- .find(params = {}) ⇒ Object
-
.task_attr(*att_names) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#complete! ⇒ Object
Marks the task as completed.
-
#delete! ⇒ Object
Deletes the task.
-
#initialize(list_id, task_series_hash, task_hash) ⇒ Task
constructor
Task series may have multiple tasks.
- #save! ⇒ Object
Methods included from DataNormalization
#normalize_rtm_tags_hash, #normalize_tags_array
Constructor Details
#initialize(list_id, task_series_hash, task_hash) ⇒ Task
Task series may have multiple tasks. task_hash used to specify which task in series.
132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/milk_cap/rtm/resources.rb', line 132 def initialize (list_id, task_series_hash, task_hash) super(task_series_hash) @task_hash = task_hash @list_id = list_id @taskseries_id = task_series_hash['id'] @task_id = @task_hash['id'] # Normalize the RTM structure and put it in TagArray = ( task_series_hash['tags'] ) @tags = TagArray.new(self, ) end |
Instance Attribute Details
#list_id ⇒ Object (readonly)
Returns the value of attribute list_id.
104 105 106 |
# File 'lib/milk_cap/rtm/resources.rb', line 104 def list_id @list_id end |
#tags ⇒ Object
Returns the value of attribute tags.
104 105 106 |
# File 'lib/milk_cap/rtm/resources.rb', line 104 def @tags end |
#task_id ⇒ Object (readonly)
Returns the value of attribute task_id.
104 105 106 |
# File 'lib/milk_cap/rtm/resources.rb', line 104 def task_id @task_id end |
#taskseries_id ⇒ Object (readonly)
Returns the value of attribute taskseries_id.
104 105 106 |
# File 'lib/milk_cap/rtm/resources.rb', line 104 def taskseries_id @taskseries_id end |
Class Method Details
.add!(name, opts = {}) ⇒ Object
Adds a new task (and returns it).
181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/milk_cap/rtm/resources.rb', line 181 def self.add! (name, opts = {}) opts = { list_id: nil, parse: true }.merge(opts) args = {} args[:name] = name args[:list_id] = opts[:list_id] if opts[:list_id] args[:timeline] = timeline args[:parse] = 1 unless !opts[:parse] h = execute('add', args) parse_tasks(h)[0] end |
.find(params = {}) ⇒ Object
174 175 176 177 |
# File 'lib/milk_cap/rtm/resources.rb', line 174 def self.find (params={}) parse_tasks(execute('getList', params)) end |
.task_attr(*att_names) ⇒ Object
:nodoc:
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/milk_cap/rtm/resources.rb', line 93 def self.task_attr (*att_names) #:nodoc: att_names.each do |att_name| class_eval %{ def #{att_name} @task_hash['#{att_name}'] end } end end |
Instance Method Details
#complete! ⇒ Object
Marks the task as completed.
162 163 164 165 |
# File 'lib/milk_cap/rtm/resources.rb', line 162 def complete! self.class.execute('complete', prepare_api_args) end |
#delete! ⇒ Object
Deletes the task.
155 156 157 158 |
# File 'lib/milk_cap/rtm/resources.rb', line 155 def delete! self.class.execute('delete', prepare_api_args) end |
#save! ⇒ Object
146 147 148 149 150 151 |
# File 'lib/milk_cap/rtm/resources.rb', line 146 def save! if self..dirty? args = prepare_api_args.merge( tags: self..join(",") ) self.class.execute('setTags', args) end end |