Class: Vermonster::Tasks::Task
- Inherits:
-
Hash
- Object
- Hash
- Vermonster::Tasks::Task
- Defined in:
- lib/vermonster/tasks.rb
Class Method Summary collapse
- .archive(list) ⇒ Object
- .archive!(list) ⇒ Object
- .create(list, options = {}) ⇒ Object
- .find(id) ⇒ Object
- .from_list(id) ⇒ Object
- .reorder(list, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Task
constructor
A new instance of Task.
- #move(list) ⇒ Object
-
#update(options = {}) ⇒ Object
Note this overrides Hash#update.
Constructor Details
#initialize(options = {}) ⇒ Task
Returns a new instance of Task.
8 9 10 11 12 13 14 15 |
# File 'lib/vermonster/tasks.rb', line 8 def initialize( = {}) self.merge!() .each do |(attr, val)| instance_variable_set("@#{attr}", val) instance_eval "def #{attr}() @#{attr} end" end end |
Class Method Details
.archive(list) ⇒ Object
48 49 50 |
# File 'lib/vermonster/tasks.rb', line 48 def archive(list) Vermonster::Client.connection.post("lists/#{list}/tasks/archive_completed") end |
.archive!(list) ⇒ Object
52 53 54 |
# File 'lib/vermonster/tasks.rb', line 52 def archive!(list) Vermonster::Client.connection.post("lists/#{list}/tasks/archive_all") end |
.create(list, options = {}) ⇒ Object
41 42 43 |
# File 'lib/vermonster/tasks.rb', line 41 def create(list, = {}) Task.new(Vermonster::Client.connection.post("lists/#{list}/tasks", "{\"task\": #{.to_json}}").body) end |
.find(id) ⇒ Object
37 38 39 |
# File 'lib/vermonster/tasks.rb', line 37 def find(id) Task.new(Vermonster::Client.connection.get("tasks/#{id}").body) end |
.from_list(id) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/vermonster/tasks.rb', line 27 def from_list(id) tasks_raw = Vermonster::Client.connection.get("lists/#{id}/tasks").body tasks = [] tasks_raw.each do |task| tasks.push(Task.new(task)) end tasks end |
.reorder(list, options = {}) ⇒ Object
45 46 |
# File 'lib/vermonster/tasks.rb', line 45 def reorder(list, = {}) end |
Instance Method Details
#move(list) ⇒ Object
22 23 24 |
# File 'lib/vermonster/tasks.rb', line 22 def move(list) self.replace(Vermonster::Client.connection.put("tasks/#{self["id"]}/move", "{\"task\": { \"list_id\": #{list} } }").body) end |
#update(options = {}) ⇒ Object
Note this overrides Hash#update. Use Hash#merge! instead.
18 19 20 |
# File 'lib/vermonster/tasks.rb', line 18 def update( = {}) self.merge!(Vermonster::Client.connection.put("tasks/#{self["id"]}", "{\"task\": #{.to_json}}").body) end |