Class: Trello::Checklist
Overview
A Checklist holds items which are like a “task” list. Checklists are linked to a card.
Instance Attribute Summary
Attributes inherited from BasicData
Class Method Summary collapse
- .create(options) ⇒ Object
-
.find(id, params = {}) ⇒ Object
Locate a specific checklist by its id.
Instance Method Summary collapse
-
#add_item(name, checked = false, position = 'bottom') ⇒ Object
Add an item to the checklist.
-
#closed? ⇒ Boolean
Check if the checklist is currently active.
-
#delete ⇒ Object
Delete a checklist.
-
#delete_checklist_item(item_id) ⇒ Object
Delete a checklist item.
-
#items ⇒ Object
Return a list of items on the checklist.
-
#members ⇒ Object
Return a list of members active in this checklist.
-
#save ⇒ Object
Save a record.
- #update! ⇒ Object
-
#update_fields(fields) ⇒ Object
Update the fields of a checklist.
Methods inherited from BasicData
#==, client, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attributes, save
Constructor Details
This class inherits a constructor from Trello::BasicData
Class Method Details
.create(options) ⇒ Object
15 16 17 18 19 |
# File 'lib/trello/checklist.rb', line 15 def create() client.create(:checklist, 'name' => [:name], 'idBoard' => [:board_id]) end |
.find(id, params = {}) ⇒ Object
Locate a specific checklist by its id.
11 12 13 |
# File 'lib/trello/checklist.rb', line 11 def find(id, params = {}) client.find(:checklist, id, params) end |
Instance Method Details
#add_item(name, checked = false, position = 'bottom') ⇒ Object
Add an item to the checklist
80 81 82 |
# File 'lib/trello/checklist.rb', line 80 def add_item(name, checked=false, position='bottom') client.post("/checklists/#{id}/checkItems", {:name => name, :checked => checked, :pos => position}) end |
#closed? ⇒ Boolean
Check if the checklist is currently active.
40 41 42 |
# File 'lib/trello/checklist.rb', line 40 def closed? closed end |
#delete ⇒ Object
Delete a checklist
90 91 92 |
# File 'lib/trello/checklist.rb', line 90 def delete client.delete("/checklists/#{id}") end |
#delete_checklist_item(item_id) ⇒ Object
Delete a checklist item
85 86 87 |
# File 'lib/trello/checklist.rb', line 85 def delete_checklist_item(item_id) client.delete("/checklists/#{id}/checkItems/#{item_id}") end |
#items ⇒ Object
Return a list of items on the checklist.
59 60 61 62 63 |
# File 'lib/trello/checklist.rb', line 59 def items check_items.map do |item_fields| Item.new(item_fields) end end |
#members ⇒ Object
Return a list of members active in this checklist.
72 73 74 75 76 77 |
# File 'lib/trello/checklist.rb', line 72 def members members = member_ids.map do |member_id| Member.find(member_id) end MultiAssociation.new(self, members).proxy end |
#save ⇒ Object
Save a record.
45 46 47 48 49 50 51 52 |
# File 'lib/trello/checklist.rb', line 45 def save return update! if id client.post("/checklists", { :name => name, :idBoard => board_id }).json_into(self) end |
#update! ⇒ Object
54 55 56 |
# File 'lib/trello/checklist.rb', line 54 def update! client.put("/checklists/#{id}", {:name => name}).json_into(self) end |
#update_fields(fields) ⇒ Object
Update the fields of a checklist.
Supply a hash of string keyed data retrieved from the Trello API representing a checklist.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/trello/checklist.rb', line 26 def update_fields(fields) attributes[:id] = fields['id'] attributes[:name] = fields['name'] attributes[:description] = fields['desc'] attributes[:closed] = fields['closed'] attributes[:url] = fields['url'] attributes[:check_items] = fields['checkItems'] attributes[:board_id] = fields['idBoard'] attributes[:list_id] = fields['idList'] attributes[:member_ids] = fields['idMembers'] self end |