Class: IssueLink

Inherits:
Object show all
Defined in:
lib/jirametrics/issue_link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin:, raw:) ⇒ IssueLink

Returns a new instance of IssueLink.



9
10
11
12
# File 'lib/jirametrics/issue_link.rb', line 9

def initialize origin:, raw:
  @origin = origin
  @raw = raw
end

Instance Attribute Details

#originObject (readonly)

Returns the value of attribute origin.



6
7
8
# File 'lib/jirametrics/issue_link.rb', line 6

def origin
  @origin
end

#other_issueObject



14
15
16
17
18
19
# File 'lib/jirametrics/issue_link.rb', line 14

def other_issue
  if @other_issue.nil?
    @other_issue = Issue.new(raw: (inward? ? raw['inwardIssue'] : raw['outwardIssue']), board: origin.board)
  end
  @other_issue
end

#rawObject (readonly)

Returns the value of attribute raw.



6
7
8
# File 'lib/jirametrics/issue_link.rb', line 6

def raw
  @raw
end

Instance Method Details

#directionObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jirametrics/issue_link.rb', line 21

def direction
  assert_jira_behaviour_false(raw['inwardIssue'].nil? && raw['outwardIssue'].nil?) do
    "Found an issue link with neither inward nor outward references: #{raw}"
  end
  assert_jira_behaviour_false(raw['inwardIssue'] && raw['outwardIssue']) do
    "Found an issue link that has both inward and outward references in the same link: #{raw}"
  end

  if raw['inwardIssue']
    :inward
  else
    :outward
  end
end

#inspectObject



56
57
58
59
# File 'lib/jirametrics/issue_link.rb', line 56

def inspect
  "IssueLink(origin=#{origin.key}, other=#{other_issue.key}, direction=#{direction}, " \
    "label=#{label.inspect}, name=#{name.inspect}"
end

#inward?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/jirametrics/issue_link.rb', line 36

def inward?
  direction == :inward
end

#labelObject



44
45
46
47
48
49
50
# File 'lib/jirametrics/issue_link.rb', line 44

def label
  if inward?
    @raw['type']['inward']
  else
    @raw['type']['outward']
  end
end

#nameObject



52
53
54
# File 'lib/jirametrics/issue_link.rb', line 52

def name
  @raw['type']['name']
end

#outward?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/jirametrics/issue_link.rb', line 40

def outward?
  direction == :outward
end