class Comment

Rubbit Object

Object that represents an individual comment

Public Class Methods

new(json) click to toggle source
# File lib/Rubbit/Rubbit_Objects.rb, line 501
def initialize(json)
        if(json['kind']=='t1')
                data = json['data']
                data.each_key do |k|
                        self.class.module_eval {attr_accessor(k)}
                        self.send("#{k}=",data[k])
                end
                children = []
                if(@replies!= nil and @replies['data']!=nil and @replies['data']['children']!=nil)
                        @replies['data']['children'].each do |c|
                                if(c!=nil)
                                        children += [Comment.new(c)]
                                end
                        end
                        @replies = children
                end
                if(@replies=="")
                        replies = nil
                end
        end
end

Public Instance Methods

delete() click to toggle source

Description

Deletes this comment. Only works if the comment was made by you.

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

Description

Modifies the text of this comment. Only works if the comment was made by you.

Attributes

  • text - The new comment body.

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

Description

No longer shows the comment to you on Reddit.

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

Description

Submits a reply to a comment.

Attributes

  • text - The body of the response

# File lib/Rubbit/Rubbit_Objects.rb, line 531
def reply(text)
        Rubbit_Poster.instance.comment(@name,text)
end