class Trello::Checklist

A Checklist holds items which are like a “task” list. Checklists are linked to a card.

@!attribute [r] id

@return [String]

@!attribute [rw] name

@return [String]

@!attribute [rw] position

@return [Object]

@!attribute [r] check_items

@return [Object]

@!attribute [r] board_id

@return [String] A 24-character hex string

@!attribute [rw] card_id

@return [String]

@!attribute [w] source_checklist_id

@return [String]

Public Instance Methods

add_item(name, checked = false, position = 'bottom') click to toggle source

Add an item to the checklist

# File lib/trello/checklist.rb, line 52
def add_item(name, checked = false, position = 'bottom')
  client.post("/checklists/#{id}/checkItems", {name: name, checked: checked, pos: position})
end
copy() click to toggle source

Copy a checklist (i.e., same attributes, items, etc.)

# File lib/trello/checklist.rb, line 76
def copy
  checklist_copy = self.class.create(name: self.name, board_id: self.board_id, card_id: self.card_id)
  copy_items_to(checklist_copy)
  return checklist_copy
end
delete() click to toggle source

Delete a checklist

# File lib/trello/checklist.rb, line 71
def delete
  client.delete("/checklists/#{id}")
end
delete_checklist_item(item_id) click to toggle source

Delete a checklist item

# File lib/trello/checklist.rb, line 66
def delete_checklist_item(item_id)
  client.delete("/checklists/#{id}/checkItems/#{item_id}")
end
items() click to toggle source

Return a list of items on the checklist.

# File lib/trello/checklist.rb, line 39
def items
  check_items.map do |item_fields|
    Item.new(item_fields)
  end
end
update_item_state(item_id, state) click to toggle source

Update a checklist item's state, e.g.: “complete” or “incomplete”

# File lib/trello/checklist.rb, line 57
def update_item_state(item_id, state)
  state = ( state ? 'complete' : 'incomplete' ) unless state.is_a?(String)
  client.put(
      "/cards/#{card_id}/checkItem/#{item_id}",
      state: state
  )
end

Private Instance Methods

copy_items_to(another_checklist) click to toggle source
# File lib/trello/checklist.rb, line 83
def copy_items_to(another_checklist)
  items.each do |item|
    another_checklist.add_item(item.name, item.complete?)
  end
end