Class: ListPullRequests::Pr

Inherits:
Object
  • Object
show all
Defined in:
lib/list_pull_requests/pr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_url, url, name, created) ⇒ Pr

Returns a new instance of Pr.



4
5
6
7
8
9
# File 'lib/list_pull_requests/pr.rb', line 4

def initialize(api_url, url, name, created)
  @api_url, @url, @name, @created = api_url, url, name, created
  split_url = url.split("/")
  @repo = split_url.fetch(-3)
  @number = split_url.last
end

Instance Attribute Details

#api_urlObject

Returns the value of attribute api_url.



2
3
4
# File 'lib/list_pull_requests/pr.rb', line 2

def api_url
  @api_url
end

#createdObject

Returns the value of attribute created.



2
3
4
# File 'lib/list_pull_requests/pr.rb', line 2

def created
  @created
end

#mergeableObject

Returns the value of attribute mergeable.



2
3
4
# File 'lib/list_pull_requests/pr.rb', line 2

def mergeable
  @mergeable
end

#mergedObject

Returns the value of attribute merged.



2
3
4
# File 'lib/list_pull_requests/pr.rb', line 2

def merged
  @merged
end

#merged_byObject

Returns the value of attribute merged_by.



2
3
4
# File 'lib/list_pull_requests/pr.rb', line 2

def merged_by
  @merged_by
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/list_pull_requests/pr.rb', line 2

def name
  @name
end

#numberObject

Returns the value of attribute number.



2
3
4
# File 'lib/list_pull_requests/pr.rb', line 2

def number
  @number
end

#repoObject

Returns the value of attribute repo.



2
3
4
# File 'lib/list_pull_requests/pr.rb', line 2

def repo
  @repo
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/list_pull_requests/pr.rb', line 2

def url
  @url
end

Instance Method Details

#lookupObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/list_pull_requests/pr.rb', line 11

def lookup
  unless @looked_up
    puts "Retrieving pull details....".red
    details = JSON.parse(open(api_url).read)
    @mergeable = details["mergeable"]
    @merged = details["merged_at"]
    @merged_by = details["merged_by"]["login"] if details["merged_by"]
    @looked_up = true
  end
end