Class: GitMarkdown::Models::PullRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/git/markdown/models/pull_request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ PullRequest

Returns a new instance of PullRequest.



8
9
10
11
12
13
14
15
16
17
# File 'lib/git/markdown/models/pull_request.rb', line 8

def initialize(attrs = {})
  @number = attrs[:number]
  @title = attrs[:title]
  @body = attrs[:body] || ""
  @state = attrs[:state]
  @author = attrs[:author]
  @html_url = attrs[:html_url]
  @created_at = attrs[:created_at]
  @updated_at = attrs[:updated_at]
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



6
7
8
# File 'lib/git/markdown/models/pull_request.rb', line 6

def author
  @author
end

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/git/markdown/models/pull_request.rb', line 6

def body
  @body
end

#created_atObject (readonly)

Returns the value of attribute created_at.



6
7
8
# File 'lib/git/markdown/models/pull_request.rb', line 6

def created_at
  @created_at
end

#html_urlObject (readonly)

Returns the value of attribute html_url.



6
7
8
# File 'lib/git/markdown/models/pull_request.rb', line 6

def html_url
  @html_url
end

#numberObject (readonly)

Returns the value of attribute number.



6
7
8
# File 'lib/git/markdown/models/pull_request.rb', line 6

def number
  @number
end

#stateObject (readonly)

Returns the value of attribute state.



6
7
8
# File 'lib/git/markdown/models/pull_request.rb', line 6

def state
  @state
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/git/markdown/models/pull_request.rb', line 6

def title
  @title
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



6
7
8
# File 'lib/git/markdown/models/pull_request.rb', line 6

def updated_at
  @updated_at
end

Class Method Details

.from_api(data) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/git/markdown/models/pull_request.rb', line 19

def self.from_api(data)
  new(
    number: data["number"],
    title: data["title"],
    body: data["body"],
    state: data["state"],
    author: data.dig("user", "login"),
    html_url: data["html_url"],
    created_at: data["created_at"],
    updated_at: data["updated_at"]
  )
end

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/git/markdown/models/pull_request.rb', line 36

def closed?
  @state == "closed"
end

#open?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/git/markdown/models/pull_request.rb', line 32

def open?
  @state == "open"
end