From 420ca5e93532ddf4db901d10cce0d8ed0c2795ee Mon Sep 17 00:00:00 2001 From: Pawel Janiak Date: Tue, 2 Dec 2014 22:35:54 +0200 Subject: [PATCH] Add reddit example --- Samples/reddit.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Samples/reddit.rb diff --git a/Samples/reddit.rb b/Samples/reddit.rb new file mode 100644 index 0000000..425298a --- /dev/null +++ b/Samples/reddit.rb @@ -0,0 +1,27 @@ +# Reddit is the front page of the internet. +# It is a collection of interest-based communities. +# +# This is a collection of simple examples using ruby +# and the reddit-kit gem to make simple reddit requests. +# +# For more information please visit: +# +# https://www.reddit.com/dev/api +# https://github.com/samsymons/RedditKit.rb + +require 'redditkit' + +RedditKit.sign_in '', '' + +front_page_links = RedditKit.front_page +front_page_links.each do |link| + puts "#{link.author} : #{link.title} - #{link.score} (#{link.num_comments} comments)" +end + +cool_user = RedditKit.user 'joot78' +puts "#{cool_user.name} is a mod on r/spiders" + +results = RedditKit.search 'koding hackathon' +results.each do |result| + puts "r/#{result.subreddit} : #{result.title} (#{result.num_comments} comments)" +end \ No newline at end of file