class Post

Rubbit Object

Object representing a Reddit Post

Public Class Methods

new(json) click to toggle source
# File lib/Rubbit/Rubbit_Objects.rb, line 570
def initialize(json)
        @comments = nil
        if(json['kind']=='t3')
                data = json['data']
                data.each_key do |k|
                        self.class.module_eval {attr_accessor(k)}
                        self.send("#{k}=",data[k])
                end
        end
end

Public Instance Methods

delete() click to toggle source

Description

Deletes this post. Only works if you made the post.

# File lib/Rubbit/Rubbit_Objects.rb, line 612
def delete
        Rubbit_Poster.instance.delete(@name)
end
edit(text) click to toggle source

Description

Modifies the text of this post. Only works if the post was made by you and is a self post.

Attributes

  • text - The new post body.

# File lib/Rubbit/Rubbit_Objects.rb, line 624
def edit(text)
        Rubbit_Poster.instance.edit(@name,text)
end
hide() click to toggle source

Description

Hides the post and no longer displays it when retrieving Reddit data

# File lib/Rubbit/Rubbit_Objects.rb, line 632
def hide
        Rubbit_Poster.instance.hide(@name)
end
mark_nsfw() click to toggle source

Description

Marks a post as NSFW. Only works if you made the post or are a moderator of the subreddit it is in.

# File lib/Rubbit/Rubbit_Objects.rb, line 640
def mark_nsfw
        Rubbit_Poster.instance.mark_nsfw(@name)
end
replies(limit=100) click to toggle source

Description

Retrieves the comments of a post in a list tree.

# File lib/Rubbit/Rubbit_Objects.rb, line 601
def replies(limit=100)
        if(@comments==nil)
                @comments = Rubbit_Object_Builder.instance.get_comments("http://www.reddit.com#{permalink}.json",limit)
        end
        return @comments
end
reply(text) click to toggle source

Description

Makes a reply to a post

Attributes

  • text - The new comment body.

# File lib/Rubbit/Rubbit_Objects.rb, line 589
def reply(text)
        return Rubbit_Poster.instance.comment(@name,text)
end
set_as_sticky(state) click to toggle source
# File lib/Rubbit/Rubbit_Objects.rb, line 593
def set_as_sticky(state)
        return Rubbit_Poster.instance.set_subreddit_sticky(@name,state)
end