class Reddit
Attributes
endpoint_url[R]
parsed_response[R]
Public Class Methods
new()
click to toggle source
# File lib/topcats/reddit.rb, line 7 def initialize @endpoint_url = 'http://www.reddit.com/r/cats/top/.json?sort=top&t=day' self.get end
Public Instance Methods
display()
click to toggle source
# File lib/topcats/reddit.rb, line 25 def display <<-EOS Today's top cat post is: Title: #{top['title']} Author: #{top['author']} Link: #{top['url']} EOS end
get()
click to toggle source
# File lib/topcats/reddit.rb, line 12 def get response = RestClient.get(endpoint_url) @parsed_response = self.parse(response) end
parse(data)
click to toggle source
# File lib/topcats/reddit.rb, line 17 def parse(data) JSON.parse(data) end
top()
click to toggle source
# File lib/topcats/reddit.rb, line 21 def top parsed_response['data']['children'].first['data'] end