Class: GitMarkdown::Models::Review

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Review

Returns a new instance of Review.



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

def initialize(attrs = {})
  @id = attrs[:id]
  @state = attrs[:state]
  @body = attrs[:body] || ""
  @author = attrs[:author]
  @html_url = attrs[:html_url]
  @submitted_at = attrs[:submitted_at]
  @comments = attrs[:comments] || []
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



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

def author
  @author
end

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#commentsObject

Returns the value of attribute comments.



7
8
9
# File 'lib/git/markdown/models/review.rb', line 7

def comments
  @comments
end

#html_urlObject (readonly)

Returns the value of attribute html_url.



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

def html_url
  @html_url
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

#submitted_atObject (readonly)

Returns the value of attribute submitted_at.



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

def 
  @submitted_at
end

Class Method Details

.from_api(data) ⇒ Object



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

def self.from_api(data)
  new(
    id: data["id"],
    state: data["state"],
    body: data["body"],
    author: data.dig("user", "login"),
    html_url: data["html_url"],
    submitted_at: data["submitted_at"]
  )
end

Instance Method Details

#approved?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/git/markdown/models/review.rb', line 30

def approved?
  @state == "APPROVED"
end

#changes_requested?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/git/markdown/models/review.rb', line 34

def changes_requested?
  @state == "CHANGES_REQUESTED"
end

#commented?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/git/markdown/models/review.rb', line 38

def commented?
  @state == "COMMENTED"
end

#dismissed?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/git/markdown/models/review.rb', line 42

def dismissed?
  @state == "DISMISSED"
end