Module: Redd::Client::Unauthenticated::Listing

Included in:
Redd::Client::Unauthenticated
Defined in:
lib/redd/client/unauthenticated/listing.rb

Instance Method Summary collapse

Instance Method Details

#by_id(*fullnames) ⇒ Object



5
6
7
8
# File 'lib/redd/client/unauthenticated/listing.rb', line 5

def by_id(*fullnames)
  names = fullnames.join(",")
  object_from_response :get,  "/by_id/#{names}.json"
end

#get_comments(*args) ⇒ Object



30
31
32
# File 'lib/redd/client/unauthenticated/listing.rb', line 30

def get_comments(*args)
  get_listing(:comments, *args)
end

#get_controversial(*args) ⇒ Object



26
27
28
# File 'lib/redd/client/unauthenticated/listing.rb', line 26

def get_controversial(*args)
  get_listing(:controversial, *args)
end

#get_hot(*args) ⇒ Object



10
11
12
# File 'lib/redd/client/unauthenticated/listing.rb', line 10

def get_hot(*args)
  get_listing(:hot, *args)
end

#get_listing(type, subreddit = nil, params = {}) ⇒ Object (private)



36
37
38
39
40
41
42
43
# File 'lib/redd/client/unauthenticated/listing.rb', line 36

def get_listing(type, subreddit = nil, params = {})
  name = extract_attribute(subreddit, :display_name) if subreddit

  path = "/#{type}.json"
  path = path.prepend("/r/#{name}") if name

  object_from_response :get, path, params
end

#get_new(*args) ⇒ Object



14
15
16
# File 'lib/redd/client/unauthenticated/listing.rb', line 14

def get_new(*args)
  get_listing(:new, *args)
end

#get_random(*args) ⇒ Object



18
19
20
# File 'lib/redd/client/unauthenticated/listing.rb', line 18

def get_random(*args)
  get_listing(:random, *args)
end

#get_top(*args) ⇒ Object



22
23
24
# File 'lib/redd/client/unauthenticated/listing.rb', line 22

def get_top(*args)
  get_listing(:top, *args)
end