Class: Senju::Issue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw, type) ⇒ Issue

Returns a new instance of Issue.



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

def initialize(raw, type)
  @raw = raw
  @type = type
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



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

def method_missing(method, *args, &block)
  case type
  when "github" then @raw[method]
  when "gitlab", "trello" then @raw.send(method)
  end
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



2
3
4
# File 'lib/senju/issue.rb', line 2

def raw
  @raw
end

#typeObject (readonly)

Returns the value of attribute type.



2
3
4
# File 'lib/senju/issue.rb', line 2

def type
  @type
end

Instance Method Details

#bodyObject



53
54
55
56
57
58
# File 'lib/senju/issue.rb', line 53

def body
  case type
  when "github" then super
  when "gitlab" then @raw.description
  end
end

#labelsObject



15
16
17
18
19
20
21
# File 'lib/senju/issue.rb', line 15

def labels
  case type
  when "github" then super.map(&:name)
  else
    super
  end
end

#noObject



31
32
33
34
35
36
37
# File 'lib/senju/issue.rb', line 31

def no
  case type
  when "github" then @raw["number"]
  when "gitlab" then @raw.iid
  when "trello" then @raw.short_id
  end
end

#ownerObject



39
40
41
42
43
44
# File 'lib/senju/issue.rb', line 39

def owner
  case type
  when "github" then @raw["user"]["login"]
  when "gitlab" then @raw.author.username
  end
end

#titleObject



23
24
25
26
27
28
29
# File 'lib/senju/issue.rb', line 23

def title
  case type
  when "trello" then name
  else
    super
  end
end

#urlObject



46
47
48
49
50
51
# File 'lib/senju/issue.rb', line 46

def url
  case type
  when "github" then @raw["html_url"]
  when "gitlab" then @raw.web_url
  end
end