Class: Startling::Github::PullRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/startling/github/pull_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes, prefetch_data: true) ⇒ PullRequest

Returns a new instance of PullRequest.



7
8
9
10
# File 'lib/startling/github/pull_request.rb', line 7

def initialize(attributes, prefetch_data: true)
  @attributes = attributes
  prefetch_data if prefetch_data
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/startling/github/pull_request.rb', line 4

def attributes
  @attributes
end

#labelsObject

Returns the value of attribute labels.



5
6
7
# File 'lib/startling/github/pull_request.rb', line 5

def labels
  @labels
end

Instance Method Details

#authorObject



44
45
46
# File 'lib/startling/github/pull_request.rb', line 44

def author
  @author ||= attributes.user.rels[:self].get.data.name
end

#branchObject



20
21
22
# File 'lib/startling/github/pull_request.rb', line 20

def branch
  attributes.head.ref
end

#created_atObject



36
37
38
# File 'lib/startling/github/pull_request.rb', line 36

def created_at
  attributes.created_at
end

#idObject



12
13
14
# File 'lib/startling/github/pull_request.rb', line 12

def id
  attributes.number
end

#in_progress?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/startling/github/pull_request.rb', line 24

def in_progress?
  label_names.any? { |label| label.match(/(WIP|REVIEW)/) }
end

#label_namesObject



28
29
30
# File 'lib/startling/github/pull_request.rb', line 28

def label_names
  labels.map(&:name)
end

#titleObject



16
17
18
# File 'lib/startling/github/pull_request.rb', line 16

def title
  attributes.title
end

#updated_atObject



40
41
42
# File 'lib/startling/github/pull_request.rb', line 40

def updated_at
  attributes.updated_at
end

#urlObject



32
33
34
# File 'lib/startling/github/pull_request.rb', line 32

def url
  attributes.rels[:html].href
end