Class: Redpomo::Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/redpomo/issue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tracker, data = {}) ⇒ Issue

Returns a new instance of Issue.



8
9
10
11
12
13
14
15
# File 'lib/redpomo/issue.rb', line 8

def initialize(tracker, data = {})
  @subject = data["subject"]
  @issue_id = data["id"]
  @project_id = data["project_id"]
  @priority_id = data["priority"]["id"] if data["priority"].present?
  @due_date = Date.parse(data["due_date"]) if data["due_date"].present?
  @tracker = tracker
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/redpomo/issue.rb', line 4

def description
  @description
end

#due_dateObject

Returns the value of attribute due_date.



6
7
8
# File 'lib/redpomo/issue.rb', line 6

def due_date
  @due_date
end

#issue_idObject

Returns the value of attribute issue_id.



5
6
7
# File 'lib/redpomo/issue.rb', line 5

def issue_id
  @issue_id
end

#priority_idObject

Returns the value of attribute priority_id.



6
7
8
# File 'lib/redpomo/issue.rb', line 6

def priority_id
  @priority_id
end

#project_idObject

Returns the value of attribute project_id.



5
6
7
# File 'lib/redpomo/issue.rb', line 5

def project_id
  @project_id
end

#subjectObject

Returns the value of attribute subject.



4
5
6
# File 'lib/redpomo/issue.rb', line 4

def subject
  @subject
end

#trackerObject

Returns the value of attribute tracker.



5
6
7
# File 'lib/redpomo/issue.rb', line 5

def tracker
  @tracker
end

Instance Method Details

#create!Object



32
33
34
35
# File 'lib/redpomo/issue.rb', line 32

def create!
  data = tracker.create_issue!(self)
  @issue_id = data["issue"]["id"]
end

#to_taskObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/redpomo/issue.rb', line 17

def to_task
  label = []
  if @priority_id.present?
    if priority = @tracker.todo_priority(@priority_id)
      label << priority
    end
  end
  label << @due_date.strftime("%Y-%m-%d") if @due_date.present?
  label << @subject
  label << "##{issue_id}"
  label << "+#{project_id}"
  label << "@#{tracker.name}"
  Task.new(nil, label.join(" "))
end