Class: GitMarkdown::Models::Comment
- Inherits:
-
Object
- Object
- GitMarkdown::Models::Comment
- Defined in:
- lib/git/markdown/models/comment.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#html_url ⇒ Object
readonly
Returns the value of attribute html_url.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#in_reply_to_id ⇒ Object
readonly
Returns the value of attribute in_reply_to_id.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#resolved ⇒ Object
Returns the value of attribute resolved.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Comment
constructor
A new instance of Comment.
- #inline? ⇒ Boolean
- #reply? ⇒ Boolean
- #resolved? ⇒ Boolean
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
#author ⇒ Object (readonly)
Returns the value of attribute author.
6 7 8 |
# File 'lib/git/markdown/models/comment.rb', line 6 def @author end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/git/markdown/models/comment.rb', line 6 def body @body end |
#created_at ⇒ Object (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_url ⇒ Object (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 |
#id ⇒ Object (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_id ⇒ Object (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 |
#line ⇒ Object (readonly)
Returns the value of attribute line.
6 7 8 |
# File 'lib/git/markdown/models/comment.rb', line 6 def line @line end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/git/markdown/models/comment.rb', line 6 def path @path end |
#resolved ⇒ Object
Returns the value of attribute resolved.
7 8 9 |
# File 'lib/git/markdown/models/comment.rb', line 7 def resolved @resolved end |
#updated_at ⇒ Object (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
36 37 38 |
# File 'lib/git/markdown/models/comment.rb', line 36 def inline? !@path.nil? end |
#reply? ⇒ Boolean
40 41 42 |
# File 'lib/git/markdown/models/comment.rb', line 40 def reply? !@in_reply_to_id.nil? end |
#resolved? ⇒ Boolean
44 45 46 |
# File 'lib/git/markdown/models/comment.rb', line 44 def resolved? @resolved == true end |