Class: GitMarkdown::Models::Comment

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Comment

Returns a new instance of Comment.



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

def initialize(attrs = {})
  @id = attrs[:id]
  @body = attrs[:body] || ""
  @author = attrs[:author]
  @path = attrs[:path]
  @line = attrs[:line]
  @html_url = attrs[:html_url]
  @created_at = attrs[:created_at]
  @updated_at = attrs[:updated_at]
  @in_reply_to_id = attrs[:in_reply_to_id]
  @resolved = attrs.fetch(:resolved, false)
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



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

def author
  @author
end

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/git/markdown/models/comment.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/comment.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/comment.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/comment.rb', line 6

def id
  @id
end

#in_reply_to_idObject (readonly)

Returns the value of attribute in_reply_to_id.



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

def in_reply_to_id
  @in_reply_to_id
end

#lineObject (readonly)

Returns the value of attribute line.



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

def line
  @line
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#resolvedObject

Returns the value of attribute resolved.



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

def resolved
  @resolved
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

Class Method Details

.from_api(data) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/git/markdown/models/comment.rb', line 22

def self.from_api(data)
  new(
    id: data["id"],
    body: data["body"],
    author: data.dig("user", "login"),
    path: data["path"],
    line: data["line"] || data["original_line"],
    html_url: data["html_url"],
    created_at: data["created_at"],
    updated_at: data["updated_at"],
    in_reply_to_id: data["in_reply_to_id"]
  )
end

Instance Method Details

#inline?Boolean

Returns:

  • (Boolean)


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

def inline?
  !@path.nil?
end

#reply?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/git/markdown/models/comment.rb', line 40

def reply?
  !@in_reply_to_id.nil?
end

#resolved?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/git/markdown/models/comment.rb', line 44

def resolved?
  @resolved == true
end