Class: Comment
- Inherits:
-
Object
- Object
- Comment
- Defined in:
- lib/Rubbit/Rubbit_Objects.rb
Overview
Rubbit Object
Object that represents an individual comment
Instance Method Summary collapse
-
#delete ⇒ Object
Description.
-
#edit(text) ⇒ Object
Description.
-
#hide ⇒ Object
Description.
-
#initialize(json) ⇒ Comment
constructor
A new instance of Comment.
-
#reply(text) ⇒ Object
Description.
Constructor Details
#initialize(json) ⇒ Comment
Returns a new instance of Comment.
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
# 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 |
Instance Method Details
#delete ⇒ Object
Description
Deletes this comment. Only works if the comment was made by you.
539 540 541 |
# File 'lib/Rubbit/Rubbit_Objects.rb', line 539 def delete Rubbit_Poster.instance.delete(@name) end |
#edit(text) ⇒ Object
Description
Modifies the text of this comment. Only works if the comment was made by you.
Attributes
-
text
- The new comment body.
551 552 553 |
# File 'lib/Rubbit/Rubbit_Objects.rb', line 551 def edit(text) Rubbit_Poster.instance.edit(@name,text) end |
#hide ⇒ Object
Description
No longer shows the comment to you on Reddit.
559 560 561 |
# File 'lib/Rubbit/Rubbit_Objects.rb', line 559 def hide Rubbit_Poster.instance.hide(@name) end |
#reply(text) ⇒ Object
Description
Submits a reply to a comment.
Attributes
-
text
- The body of the response
531 532 533 |
# File 'lib/Rubbit/Rubbit_Objects.rb', line 531 def reply(text) Rubbit_Poster.instance.comment(@name,text) end |