Sha256: 567b39b4ca1eff96e24cf8359be5a5bbb71356165fc9e00b6b95a39b16450f14
Contents?: true
Size: 1.5 KB
Versions: 4
Compression:
Stored size: 1.5 KB
Contents
module TrelloFlow module Api class Item < Base delegate :card, :card_id, to: :checklist def self.fields [:description, :owners] end def self.find(checklist_id, item_id) with("checklists/#{checklist_id}/checkItems/#{item_id}").find_one end def description if complete? checkmark + name_without_mentions else name_without_mentions end end def owners mentions.join(", ") end def color :green if complete? end def assign(owner) return if mentions.include?(owner.username) self.class.request :put, "cards/#{card_id}/checklist/#{checklist_id}/checkItem/#{id}/name", value: name_without_mentions + " @#{owner.username}" card.add_member(owner) end def complete self.class.request :put, "cards/#{card_id}/checklist/#{checklist_id}/checkItem/#{id}/state", value: "complete" end def to_param name_without_mentions.parameterize[0..50] end def name_without_mentions (name.split - mentions).join(" ").strip end private def checklist @_checklist ||= Checklist.find checklist_id end def checklist_id attributes[:idChecklist] end def mentions name.scan(/(@\S+)/).flatten end def checkmark "\u2713 " end def complete? state == "complete" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
trello_flow-1.3.0 | lib/trello_flow/api/item.rb |
trello_flow-1.2.2 | lib/trello_flow/api/item.rb |
trello_flow-1.2.1 | lib/trello_flow/api/item.rb |
trello_flow-1.2.0 | lib/trello_flow/api/item.rb |