class ReplTalk::Post
Attributes
answer[R]
board[R]
can_vote[R]
comment_count[R]
content[R]
has_voted[R]
id[R]
is_announcement[R]
is_answerable[R]
is_answered[R]
is_locked[R]
is_pinned[R]
preview[R]
repl[R]
timestamp[R]
title[R]
url[R]
vote_count[R]
Public Class Methods
new(client, post)
click to toggle source
# File lib/repltalk/structures.rb, line 403 def initialize(client, post) @client = client @id = post["id"] @url = $BASE_URL + post["url"] @title = post["title"] @content = post["body"] @preview = post["preview"] @timestamp = post["timeCreated"] @board = Board.new(post["board"]) @repl = post["repl"] == nil ? nil : Repl.new(@client, post["repl"]) @author = post["user"] == nil ? nil : User.new(@client, post["user"]) @answer = post["answer"] == nil ? nil : Comment.new(@client, post["answer"]) @vote_count = post["voteCount"] @comment_count = post["commentCount"] @can_vote = post["canVote"] @has_voted = post["hasVoted"] @is_answered = post["isAnswered"] @is_answerable = post["isAnswerable"] @is_hidden = post["isHidden"] @is_pinned = post["isPinned"] @is_locked = post["isLocked"] @is_announcement = post["isAnnouncement"] end
Public Instance Methods
create_comment(content)
click to toggle source
# File lib/repltalk/structures.rb, line 455 def create_comment(content) c = @client.graphql( "createComment", GQL::Mutations::CREATE_COMMENT, input: { postId: @id, body: content } ) Comment.new(@client, c["createComment"]["comment"]) end
delete()
click to toggle source
# File lib/repltalk/structures.rb, line 482 def delete @client.graphql( "deletePost", GQL::Mutations::DELETE_POST, id: @id ) nil end
edit(title: @title, content: @content, repl_id: @repl.id, show_hosted: false)
click to toggle source
# File lib/repltalk/structures.rb, line 467 def edit(title: @title, content: @content, repl_id: @repl.id, show_hosted: false) p = @client.graphql( "updatePost", GQL::Mutations::EDIT_POST, input: { id: @id, title: title, body: content, replId: repl_id, showHosted: show_hosted } ) Post.new(@client, p["updatePost"]["post"]) end
get_comments(order: "new", count: nil, after: nil)
click to toggle source
# File lib/repltalk/structures.rb, line 433 def get_comments(order: "new", count: nil, after: nil) c = @client.graphql( "post", GQL::Queries::GET_POSTS_COMMENTS, postId: @id, order: order, count: count, after: after ) c["post"]["comments"]["items"].map { |comment| Comment.new(@client, comment) } end
get_upvotes(count: nil)
click to toggle source
# File lib/repltalk/structures.rb, line 445 def get_upvotes(count: nil) u = @client.graphql( "post", GQL::Queries::GET_POSTS_UPVOTERS, id: @id, count: count ) u["post"]["votes"]["items"].map { |vote| User.new(@client, vote["user"]) } end
report(reason)
click to toggle source
# File lib/repltalk/structures.rb, line 491 def report(reason) @client.graphql( "createBoardReport", GQL::Mutations::REPORT_POST, id: @id, reason: reason ) nil end
to_s()
click to toggle source
# File lib/repltalk/structures.rb, line 501 def to_s @title end