Class: Trello::Card
- Inherits:
-
Object
- Object
- Trello::Card
- Defined in:
- lib/trello-lite/card.rb
Instance Attribute Summary collapse
-
#activities(limit = 5) ⇒ Object
Returns the value of attribute activities.
-
#activities_url ⇒ Object
Returns the value of attribute activities_url.
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#members ⇒ Object
Returns the value of attribute members.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #card_json ⇒ Object
- #create_members ⇒ Object
- #due ⇒ Object
- #due_complete ⇒ Object
- #id ⇒ Object
-
#initialize(attrs = {}) ⇒ Card
constructor
A new instance of Card.
- #last_activity ⇒ Object
- #name ⇒ Object
- #short_link ⇒ Object
- #status ⇒ Object
- #work_units ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Card
Returns a new instance of Card.
5 6 7 8 9 10 11 12 |
# File 'lib/trello-lite/card.rb', line 5 def initialize(attrs = {}) @attributes = attrs @url = "https://api.trello.com/1/cards/#{attributes[:id]}?fields=all&members=true&member_fields=fullName%2Cusername&#{Trello.credentials}" @activities_url = "https://api.trello.com/1/cards/#{attributes[:id]}/actions?limit=5&#{Trello.credentials}" @card_json = nil @activities = [] @members = [] end |
Instance Attribute Details
#activities(limit = 5) ⇒ Object
Returns the value of attribute activities.
3 4 5 |
# File 'lib/trello-lite/card.rb', line 3 def activities @activities end |
#activities_url ⇒ Object
Returns the value of attribute activities_url.
3 4 5 |
# File 'lib/trello-lite/card.rb', line 3 def activities_url @activities_url end |
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/trello-lite/card.rb', line 3 def attributes @attributes end |
#members ⇒ Object
Returns the value of attribute members.
3 4 5 |
# File 'lib/trello-lite/card.rb', line 3 def members @members end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/trello-lite/card.rb', line 3 def url @url end |
Instance Method Details
#card_json ⇒ Object
26 27 28 |
# File 'lib/trello-lite/card.rb', line 26 def card_json @card_json ||= Trello.parse(url) end |
#create_members ⇒ Object
49 50 51 52 53 |
# File 'lib/trello-lite/card.rb', line 49 def create_members card_json[:members].each do |member| @members << Member.new(member) end end |
#due ⇒ Object
22 23 24 |
# File 'lib/trello-lite/card.rb', line 22 def due Time.parse(card_json[:due]).strftime("%d/%m/%Y") end |
#due_complete ⇒ Object
34 35 36 |
# File 'lib/trello-lite/card.rb', line 34 def due_complete card_json[:dueComplete] end |
#id ⇒ Object
14 15 16 |
# File 'lib/trello-lite/card.rb', line 14 def id attributes[:id] end |
#last_activity ⇒ Object
30 31 32 |
# File 'lib/trello-lite/card.rb', line 30 def last_activity Time.parse(card_json[:dateLastActivity]).strftime("%d/%m/%Y") end |
#name ⇒ Object
18 19 20 |
# File 'lib/trello-lite/card.rb', line 18 def name attributes[:name] end |
#short_link ⇒ Object
38 39 40 |
# File 'lib/trello-lite/card.rb', line 38 def short_link card_json[:shortUrl] end |
#status ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/trello-lite/card.rb', line 55 def status unless due_complete days = Date.parse(Time.now.strftime('%d/%m/%Y')) - Date.parse(due) "Delayed by #{days.to_i} days" else "Done" end end |
#work_units ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/trello-lite/card.rb', line 64 def work_units url = "https://api.trello.com/1/cards/#{id}/customFieldItems?" + Trello.credentials data = Trello.parse(url) updated_data = data.select {|plugin| plugin[:value].keys.include?(:number)} if updated_data.empty? puts "kindly add work units" else updated_data[0][:value][:number].to_i end end |