class ReplTalk::ReplComment

Attributes

author[R]
content[R]
id[R]
repl[R]
replies[R]

Public Class Methods

new(client, comment) click to toggle source
# File lib/repltalk/structures.rb, line 129
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

Public Instance Methods

create_comment(content) click to toggle source
# File lib/repltalk/structures.rb, line 139
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() click to toggle source
# File lib/repltalk/structures.rb, line 163
def delete
        @client.graphql(
                "ReplViewCommentsDeleteReplComment",
                GQL::Mutations::DELETE_REPL_COMMENT,
                id: @id
        )
        nil
end
edit(content) click to toggle source
# File lib/repltalk/structures.rb, line 151
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() click to toggle source
# File lib/repltalk/structures.rb, line 172
def to_s
        @content
end