From 93d83d300890e50260bef10852c81b0a03992666 Mon Sep 17 00:00:00 2001
From: james cook Returns:
diff --git a/doc/Reddit/Api.html b/doc/Reddit/Api.html
index 5b057ef..f51d315 100644
--- a/doc/Reddit/Api.html
+++ b/doc/Reddit/Api.html
@@ -832,7 +832,7 @@ Returns:
diff --git a/doc/Reddit/Base.html b/doc/Reddit/Base.html
index e63f681..e2f9bf6 100644
--- a/doc/Reddit/Base.html
+++ b/doc/Reddit/Base.html
@@ -1639,7 +1639,7 @@ Returns:
diff --git a/doc/Reddit/Comment.html b/doc/Reddit/Comment.html
index f111665..75dd7b7 100644
--- a/doc/Reddit/Comment.html
+++ b/doc/Reddit/Comment.html
@@ -478,6 +478,33 @@ Instance Attribute Summary (collap
+Returns the value of attribute replies. +
++Parse nested comment hashes into a Comment. +
+- - (Comment) initialize(json) + - (Comment) initialize(json, options = {}) @@ -957,13 +1008,41 @@
# File 'lib/ruby_reddit_api/comment.rb', line 7 -def initialize(json) - parse(json) +def initialize(json, ={}) + mode = .fetch(:mode){ :json } + if mode == :json + parse(json) + end + + if mode == :replies + json.keys.each do |key| + instance_variable_set("@#{key}", json[key]) + end + end + + if replies.is_a?(Hash) + handle_replies(replies) + end + @debug = StringIO.new end
+ + - (Object) replies (readonly) + + + +
+Returns the value of attribute replies +
+ + +
+ + + +6 +7 +8+ |
+
+ # File 'lib/ruby_reddit_api/comment.rb', line 6 + +def replies + @replies +end+ |
+
-90 -91 -92 -93 -94+104 +105 +106 +107
# File 'lib/ruby_reddit_api/comment.rb', line 90 +# File 'lib/ruby_reddit_api/comment.rb', line 104 def add_distinction(verb) resp=self.class.post("/api/distinguish/#{verb}", {:body => {:id => id, :uh => modhash, :r => subreddit, :executed => "distinguishing..."}, :headers => base_headers, :debug_output => @debug }) - puts resp.headers resp.code == 200 end
-64 -65 -66+78 +79 +80
# File 'lib/ruby_reddit_api/comment.rb', line 64 +# File 'lib/ruby_reddit_api/comment.rb', line 78 def admin_distinguish add_distinction "admin" @@ -1752,13 +1871,13 @@Returns:
-55 -56 -57 -58+69 +70 +71 +72
# File 'lib/ruby_reddit_api/comment.rb', line 55 +# File 'lib/ruby_reddit_api/comment.rb', line 69 def approve resp=self.class.post("/api/approve", {:body => {:id => id, :uh => modhash, :r => subreddit}, :headers => base_headers, :debug_output => @debug }) @@ -1806,17 +1925,17 @@Returns:
-23 -24 -25 -26 -27 -28 -29 -30+37 +38 +39 +40 +41 +42 +43 +44
# File 'lib/ruby_reddit_api/comment.rb', line 23 +# File 'lib/ruby_reddit_api/comment.rb', line 37 def comments opts = {:handler => "Comment", @@ -1868,13 +1987,13 @@Returns:
-34 -35 -36 -37+48 +49 +50 +51
# File 'lib/ruby_reddit_api/comment.rb', line 34 +# File 'lib/ruby_reddit_api/comment.rb', line 48 def edit(newtext) resp=self.class.post("/api/editusertext", {:body => {:thing_id => id, :uh => modhash, :r => subreddit, :text => newtext }, :headers => base_headers, :debug_output => @debug }) @@ -1883,6 +2002,91 @@Returns:
+ + - (true) handle_replies(data) + + + +
+Parse nested comment hashes into a Comment +
+ + +
+ + + +112 +113 +114 +115 +116 +117 +118 +119 +120+ |
+
+ # File 'lib/ruby_reddit_api/comment.rb', line 112 + +def handle_replies(data) + dup = data.dup + _kind, data = dup["kind"], dup["data"] + modhash, children = data["modhash"], data["children"] + if children.is_a?(Array) + @replies = children.map{|reply| Comment.new(reply["data"], :mode => :replies) } + end + true +end+ |
+
-41 -42 -43 -44+55 +56 +57 +58
# File 'lib/ruby_reddit_api/comment.rb', line 41 +# File 'lib/ruby_reddit_api/comment.rb', line 55 def resp=self.class.post("/api/del", {:body => {:id => id, :uh => modhash, :r => subreddit, :executed => "removed" }, :headers => base_headers, :debug_output => @debug }) @@ -1952,12 +2156,12 @@Returns:
-68 -69 -70+82 +83 +84
# File 'lib/ruby_reddit_api/comment.rb', line 68 +# File 'lib/ruby_reddit_api/comment.rb', line 82 def indistinguish add_distinction "no" @@ -1980,15 +2184,15 @@Returns:
-12 -13 -14+26 +27 +28
# File 'lib/ruby_reddit_api/comment.rb', line 12 +# File 'lib/ruby_reddit_api/comment.rb', line 26 def inspect - "<Reddit::Comment author='#{@author}' body='#{short_body}'>" + "<Reddit::Comment author='#{@author}' body='#{short_body}' replies='#{replies.size}' ups='#{ups}' downs='#{downs}'>" end
-60 -61 -62+74 +75 +76
# File 'lib/ruby_reddit_api/comment.rb', line 60 +# File 'lib/ruby_reddit_api/comment.rb', line 74 def moderator_distinguish add_distinction "yes" @@ -2060,13 +2264,13 @@Returns:
-48 -49 -50 -51+62 +63 +64 +65
# File 'lib/ruby_reddit_api/comment.rb', line 48 +# File 'lib/ruby_reddit_api/comment.rb', line 62 def remove resp=self.class.post("/api/remove", {:body => {:id => id, :uh => modhash, :r => subreddit}, :headers => base_headers, :debug_output => @debug }) @@ -2114,13 +2318,13 @@Returns:
-74 -75 -76 -77+88 +89 +90 +91
# File 'lib/ruby_reddit_api/comment.rb', line 74 +# File 'lib/ruby_reddit_api/comment.rb', line 88 def reply(text) resp = self.class.post("/api/comment", {:body => {:thing_id => id, :text => text, :uh => modhash, :r => subreddit }, :headers => base_headers, :debug_output => @debug }) @@ -2168,20 +2372,20 @@Returns:
-81 -82 -83 -84 -85 -86 -87 -88+95 +96 +97 +98 +99 +100 +101 +102
# File 'lib/ruby_reddit_api/comment.rb', line 81 +# File 'lib/ruby_reddit_api/comment.rb', line 95 def short_body - str = body.to_s + str = body.to_s.strip if str.size > 15 str[0..15] + "..." else @@ -2227,12 +2431,12 @@Returns:
-17 -18 -19+31 +32 +33
# File 'lib/ruby_reddit_api/comment.rb', line 17 +# File 'lib/ruby_reddit_api/comment.rb', line 31 def to_s body @@ -2247,7 +2451,7 @@Returns:
diff --git a/doc/Reddit/JsonListing.html b/doc/Reddit/JsonListing.html index 3faf7ed..2d3f219 100644 --- a/doc/Reddit/JsonListing.html +++ b/doc/Reddit/JsonListing.html @@ -154,7 +154,7 @@Class Method Details
diff --git a/doc/Reddit/JsonListing/ClassMethods.html b/doc/Reddit/JsonListing/ClassMethods.html index af9b664..d7d1910 100644 --- a/doc/Reddit/JsonListing/ClassMethods.html +++ b/doc/Reddit/JsonListing/ClassMethods.html @@ -214,7 +214,7 @@Returns:
diff --git a/doc/Reddit/JsonListing/InstanceMethods.html b/doc/Reddit/JsonListing/InstanceMethods.html index abb550d..c6389c7 100644 --- a/doc/Reddit/JsonListing/InstanceMethods.html +++ b/doc/Reddit/JsonListing/InstanceMethods.html @@ -192,7 +192,7 @@Returns:
diff --git a/doc/Reddit/Message.html b/doc/Reddit/Message.html index f17c6d7..1a0637b 100644 --- a/doc/Reddit/Message.html +++ b/doc/Reddit/Message.html @@ -1542,7 +1542,7 @@Returns:
diff --git a/doc/Reddit/Submission.html b/doc/Reddit/Submission.html index 0f2d53a..e71e2ba 100644 --- a/doc/Reddit/Submission.html +++ b/doc/Reddit/Submission.html @@ -2654,7 +2654,7 @@Returns:
diff --git a/doc/Reddit/Thing.html b/doc/Reddit/Thing.html index fda44c6..b2540df 100644 --- a/doc/Reddit/Thing.html +++ b/doc/Reddit/Thing.html @@ -677,7 +677,7 @@Returns:
diff --git a/doc/Reddit/User.html b/doc/Reddit/User.html index 010302c..61b6fd8 100644 --- a/doc/Reddit/User.html +++ b/doc/Reddit/User.html @@ -1238,7 +1238,7 @@Returns:
diff --git a/doc/Reddit/Vote.html b/doc/Reddit/Vote.html index c2f1433..9726d5d 100644 --- a/doc/Reddit/Vote.html +++ b/doc/Reddit/Vote.html @@ -492,7 +492,7 @@Returns:
diff --git a/doc/_index.html b/doc/_index.html index 253e8f3..2690a10 100644 --- a/doc/_index.html +++ b/doc/_index.html @@ -245,7 +245,7 @@Namespace Listing A-Z
diff --git a/doc/file.README.html b/doc/file.README.html index 2ee03ab..a35ab2b 100644 --- a/doc/file.README.html +++ b/doc/file.README.html @@ -123,7 +123,7 @@- Set up the reddit VM ( - Generated on Wed Oct 6 23:21:39 2010 by + Generated on Sun Oct 10 01:18:34 2010 by yard 0.6.1 (ruby-1.9.2). diff --git a/doc/index.html b/doc/index.html index 2ee03ab..a35ab2b 100644 --- a/doc/index.html +++ b/doc/index.html @@ -123,7 +123,7 @@
- Set up the reddit VM ( - Generated on Wed Oct 6 23:21:39 2010 by + Generated on Sun Oct 10 01:18:34 2010 by yard 0.6.1 (ruby-1.9.2). diff --git a/doc/method_list.html b/doc/method_list.html index fa55919..46f298b 100644 --- a/doc/method_list.html +++ b/doc/method_list.html @@ -77,17 +77,17 @@
Method List