Created
July 31, 2013 16:32
-
-
Save mecampbellsoup/6123659 to your computer and use it in GitHub Desktop.
surprising result - was hoping the with_index would allow me give each subreddit an :id without persisting to database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest_client' | |
require 'pry' | |
require 'json' | |
def get_subreddits | |
parsed_response = JSON.load(RestClient.get("http://reddit.com/reddits.json")) | |
parsed_response["data"]["children"].each_with_index do |subreddit,i| | |
{ subreddit: subreddit["data"]["url"], image: subreddit["data"]["header_img"], name: subreddit["data"]["display_name"], id: i } | |
end | |
end | |
p get_subreddits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment