Permalink
Browse files

Merge pull request #1 from chetan51/master

Fixed bug in retrieving comments for an article
  • Loading branch information...
2 parents a71e0d1 + 903e16e commit f693861e90560c192ba9e211501e737a6ed9e2aa @bterlson committed Oct 22, 2011
Showing with 4 additions and 2 deletions.
  1. +3 −1 lib/reddit/article.rb
  2. +1 −1 lib/reddit/comment.rb
View
@@ -1,7 +1,7 @@
module Reddit
# A reddit article or submission.
class Article
- attr_reader :score, :name, :title, :comment_count, :ups, :downs, :url, :domain, :author, :id, :created_at
+ attr_reader :score, :name, :title, :comment_count, :ups, :downs, :url, :domain, :author, :id, :created_at, :selftext, :selftext_html
# Initializes the data for the article. Takes a hash of the various attributes as taken from the API.
def initialize(attributes)
@@ -20,6 +20,8 @@ def initialize(attributes)
@saved = attributes['saved']
@clicked = attributes['clicked']
@hidden = attributes['hidden']
+ @selftext = attributes['selftext']
+ @selftext_html = attributes['selftext_html']
end
# indicates if the current logged in user has saved the article.
View
@@ -15,7 +15,7 @@ def initialize(attributes)
@body = attributes['body']
@replies = []
- unless attributes['replies'].nil?
+ unless attributes['replies'].nil? or attributes['replies']['data'].nil? or attributes['replies']['data']['children']
attributes['replies']['data']['children'].each do |reply|
@replies << Comment.new(reply['data'])
end

0 comments on commit f693861

Please sign in to comment.