Class: Lionel::ProxyCard
- Inherits:
-
Object
- Object
- Lionel::ProxyCard
- Extended by:
- Forwardable
- Defined in:
- lib/lionel/proxy_card.rb
Constant Summary collapse
- MAX_ACTIONS =
1000
Instance Attribute Summary collapse
-
#card ⇒ Object
readonly
Returns the value of attribute card.
Instance Method Summary collapse
- #action_date(&block) ⇒ Object
- #actions(options = {}) ⇒ Object
- #checklist_count(name) ⇒ Object
- #date_moved_to(list_name) ⇒ Object
- #due_date ⇒ Object
- #estimate ⇒ Object
- #first_action(&block) ⇒ Object
- #format_date(date, format = "%m/%d/%Y") ⇒ Object
-
#initialize(card) ⇒ ProxyCard
constructor
A new instance of ProxyCard.
- #labels ⇒ Object
- #link(name = card.name) ⇒ Object
- #project ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(card) ⇒ ProxyCard
Returns a new instance of ProxyCard.
9 10 11 |
# File 'lib/lionel/proxy_card.rb', line 9 def initialize(card) @card = card end |
Instance Attribute Details
#card ⇒ Object (readonly)
Returns the value of attribute card.
5 6 7 |
# File 'lib/lionel/proxy_card.rb', line 5 def card @card end |
Instance Method Details
#action_date(&block) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/lionel/proxy_card.rb', line 23 def action_date(&block) filtered = actions.select(&block) return "" if filtered.empty? action = filtered.sort { |a, b| a.date <=> b.date }.first format_date action.date end |
#actions(options = {}) ⇒ Object
18 19 20 21 |
# File 'lib/lionel/proxy_card.rb', line 18 def actions( = {}) [:limit] = .fetch(:limit, MAX_ACTIONS) @actions ||= card.actions().map { |a| Lionel::ProxyAction.new(a) } end |
#checklist_count(name) ⇒ Object
66 67 68 69 70 |
# File 'lib/lionel/proxy_card.rb', line 66 def checklist_count(name) checklist = card.checklists.find { |chl| chl.name == name } return 0 unless checklist checklist.check_items.count end |
#date_moved_to(list_name) ⇒ Object
30 31 32 33 34 |
# File 'lib/lionel/proxy_card.rb', line 30 def date_moved_to(list_name) action = first_action { |a| a.moved_to?(list_name) } return "" unless action format_date(action.date) end |
#due_date ⇒ Object
62 63 64 |
# File 'lib/lionel/proxy_card.rb', line 62 def due_date format_date(due) if due end |
#estimate ⇒ Object
56 57 58 59 60 |
# File 'lib/lionel/proxy_card.rb', line 56 def estimate match = card.name.match(/\[(?<estimate>\w+)\]/) return "" unless match match[:estimate] end |
#first_action(&block) ⇒ Object
40 41 42 |
# File 'lib/lionel/proxy_card.rb', line 40 def first_action(&block) actions.select(&block).sort { |a, b| a.date <=> b.date }.first end |
#format_date(date, format = "%m/%d/%Y") ⇒ Object
36 37 38 |
# File 'lib/lionel/proxy_card.rb', line 36 def format_date(date, format = "%m/%d/%Y") date.strftime(format) end |
#labels ⇒ Object
52 53 54 |
# File 'lib/lionel/proxy_card.rb', line 52 def labels @labels ||= card.labels.map(&:name).map(&:downcase) end |
#link(name = card.name) ⇒ Object
13 14 15 |
# File 'lib/lionel/proxy_card.rb', line 13 def link(name = card.name) %Q[=HYPERLINK("#{card.url}", "#{name.gsub(/"/, "")}")] end |
#project ⇒ Object
48 49 50 |
# File 'lib/lionel/proxy_card.rb', line 48 def project labels.detect { |l| l !~ %r{bug|chore|task}i } end |
#type ⇒ Object
44 45 46 |
# File 'lib/lionel/proxy_card.rb', line 44 def type labels.detect { |l| l =~ %r{bug|chore|task}i } || 'story' end |