Class: ReplTalk::ReplComment
- Inherits:
-
Object
- Object
- ReplTalk::ReplComment
- Defined in:
- lib/repltalk/structures.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#repl ⇒ Object
readonly
Returns the value of attribute repl.
-
#replies ⇒ Object
readonly
Returns the value of attribute replies.
Instance Method Summary collapse
- #create_comment(content) ⇒ Object
- #delete ⇒ Object
- #edit(content) ⇒ Object
-
#initialize(client, comment) ⇒ ReplComment
constructor
A new instance of ReplComment.
- #to_s ⇒ Object
Constructor Details
#initialize(client, comment) ⇒ ReplComment
Returns a new instance of ReplComment.
87 88 89 90 91 92 93 94 95 |
# File 'lib/repltalk/structures.rb', line 87 def initialize(client, comment) @client = client @id = comment["id"] @content = comment["body"] @author = comment["user"] == nil ? nil : User.new(@client, comment["user"]) @repl = comment["repl"] == nil ? nil : Repl.new(@client, comment["repl"]) @replies = comment["replies"] == nil ? nil : comment["replies"].map { |c| ReplComment.new(@client, c) } end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
85 86 87 |
# File 'lib/repltalk/structures.rb', line 85 def @author end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
85 86 87 |
# File 'lib/repltalk/structures.rb', line 85 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
85 86 87 |
# File 'lib/repltalk/structures.rb', line 85 def id @id end |
#repl ⇒ Object (readonly)
Returns the value of attribute repl.
85 86 87 |
# File 'lib/repltalk/structures.rb', line 85 def repl @repl end |
#replies ⇒ Object (readonly)
Returns the value of attribute replies.
85 86 87 |
# File 'lib/repltalk/structures.rb', line 85 def replies @replies end |
Instance Method Details
#create_comment(content) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/repltalk/structures.rb', line 97 def create_comment(content) c = @client.graphql( "ReplViewCreateReplCommentReply", GQL::Mutations::REPLY_REPL_COMMENT, input: { replCommentId: @id, body: content } ) ReplComment.new(@client, c["createReplCommentReply"]) end |
#delete ⇒ Object
121 122 123 124 125 126 127 128 |
# File 'lib/repltalk/structures.rb', line 121 def delete @client.graphql( "ReplViewCommentsDeleteReplComment", GQL::Mutations::DELETE_REPL_COMMENT, id: @id ) nil end |
#edit(content) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/repltalk/structures.rb', line 109 def edit(content) c = @client.graphql( "ReplViewCommentsUpdateReplComment", GQL::Mutations::EDIT_REPL_COMMENT, input: { id: @id, body: content } ) ReplComment.new(@client, c["updateReplComment"]) end |
#to_s ⇒ Object
130 131 132 |
# File 'lib/repltalk/structures.rb', line 130 def to_s @content end |