lib/tumblr/reader.rb in tumblr-rb-1.1.0 vs lib/tumblr/reader.rb in tumblr-rb-1.1.1
- old
+ new
@@ -42,13 +42,15 @@
# Get the Posts as Post objects from a Read response.
# Pass an additional type parameter to only get Posts of a certain type.
def self.get_posts(response, type = nil)
tumblr_post = response['tumblr']['posts']['post']
- posts = tumblr_post.respond_to?(:each_pair) ? [tumblr_post] : tumblr_post
- posts.collect! { |post| build_post(post) }
- return posts.select {|post| post.is_a?(Tumblr.map(type)) } if type
- posts
+ if tumblr_post
+ posts = tumblr_post.respond_to?(:each_pair) ? [tumblr_post] : tumblr_post
+ posts.collect! { |post| build_post(post) }
+ return posts.select {|post| post.is_a?(Tumblr.map(type)) } if type
+ posts
+ end
end
# Build a Post object from Reader's Post XML
def self.build_post(post)
setup_post(post) do |tumblr_post|
\ No newline at end of file