Class: Gitgut::Github::PullRequest

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

Overview

A Github pull request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ PullRequest

Returns a new instance of PullRequest.



14
15
16
17
18
19
20
21
# File 'lib/gitgut/github.rb', line 14

def initialize(payload)
  @number = payload[:number].to_s
  @state = payload[:state]
  # @url = payload[:url]
  # @title = payload[:title]
  @merged_at = payload[:merged_at]
  # @closed_at = payload[:closed_at]
end

Instance Attribute Details

#merged_atObject (readonly)

Returns the value of attribute merged_at.



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

def merged_at
  @merged_at
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

Instance Method Details

#colorObject



23
24
25
26
27
28
29
30
# File 'lib/gitgut/github.rb', line 23

def color
  case state
  when 'open'
    :white
  when 'closed'
    merged? ? :green : :light_black
  end
end

#merged?Boolean

Returns:

  • (Boolean)


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

def merged?
  !@merged_at.nil?
end