Class: Reddit

Inherits:
Object
  • Object
show all
Defined in:
lib/reddinfo.rb

Overview

Main Treehouse Class

Class Method Summary collapse

Class Method Details

.frontObject



16
17
18
19
# File 'lib/reddinfo.rb', line 16

def self.front
  json = Net::HTTP.get(URI.parse('http://reddit.com/.json'))
  JSON.parse(json)
end

.subreddit(subreddit) ⇒ Object



8
9
10
11
# File 'lib/reddinfo.rb', line 8

def self.subreddit(subreddit)
  json = Net::HTTP.get(URI.parse('http://reddit.com' + '/r/' + subreddit + '/.json'))
  JSON.parse(json)
end

.user(user) ⇒ Object



12
13
14
15
# File 'lib/reddinfo.rb', line 12

def self.user(user)
  json = Net::HTTP.get(URI.parse('http://reddit.com' + '/u/' + user + '/.json'))
  JSON.parse(json)
end