class ReplTalk::Comment
Attributes
can_vote[R]
content[R]
has_voted[R]
id[R]
is_answer[R]
post_id[R]
timestamp[R]
url[R]
vote_count[R]
Public Class Methods
new(client, comment)
click to toggle source
# File lib/repltalk/structures.rb, line 306 def initialize(client, comment) @client = client @id = comment["id"] @url = $BASE_URL + comment["url"] @author = comment["user"] == nil ? "[deleted user]" : User.new(@client, comment["user"]) @content = comment["body"] @post_id = comment["post"]["id"] @is_answer = comment["isAnswer"] @vote_count = comment["voteCount"] @timestamp = comment["timeCreated"] @can_vote = comment["canVote"] @has_voted = comment["hasVoted"] end
Public Instance Methods
create_comment(content)
click to toggle source
# File lib/repltalk/structures.rb, line 349 def create_comment(content) c = @client.graphql( "createComment", GQL::Mutations::CREATE_COMMENT, input: { postId: @post_id, commentId: @id, body: content } ) Comment.new(@client, c["createComment"]["comment"]) end
delete()
click to toggle source
# File lib/repltalk/structures.rb, line 374 def delete @client.graphql( "deleteComment", GQL::Mutations::DELETE_COMMENT, id: @id ) nil end
edit(content)
click to toggle source
# File lib/repltalk/structures.rb, line 362 def edit(content) c = @client.graphql( "updateComment", GQL::Mutations::EDIT_COMMENT, input: { id: @id, body: content } ) Comment.new(@client, c["updateComment"]["comment"]) end
get_comments()
click to toggle source
# File lib/repltalk/structures.rb, line 331 def get_comments c = @client.graphql( "comment", GQL::Queries::GET_COMMENTS_COMMENTS, id: @id ) c["comment"]["comments"].map { |comment| Comment.new(@client, comment) } end
get_parent()
click to toggle source
# File lib/repltalk/structures.rb, line 340 def get_parent c = @client.graphql( "comment", GQL::Queries::GET_PARENT_COMMENT, id: @id ) c["comment"]["parentComment"] == nil ? nil : Comment.new(@client, c["comment"]["parentComment"]) end
get_post()
click to toggle source
# File lib/repltalk/structures.rb, line 322 def get_post p = @client.graphql( "post", GQL::Queries::GET_POST, id: @post_id ) Post.new(@client, p["post"]) end
report(reason)
click to toggle source
# File lib/repltalk/structures.rb, line 383 def report(reason) @client.graphql( "createBoardReport", GQL::Mutations::REPORT_COMMENT, id: @id, reason: reason ) nil end
to_s()
click to toggle source
# File lib/repltalk/structures.rb, line 393 def to_s @content end