Class: Reddit

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

Overview

Main Treehouse Class

Class Method Summary collapse

Class Method Details

.frontObject



18
19
20
21
# File 'lib/reddinfo.rb', line 18

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

.subreddit(subreddit) ⇒ Object



10
11
12
13
# File 'lib/reddinfo.rb', line 10

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

.user(user) ⇒ Object



14
15
16
17
# File 'lib/reddinfo.rb', line 14

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

.versionObject



22
23
24
# File 'lib/reddinfo.rb', line 22

def self.version
  puts "reddinfo v#{VERSION}"
end