module Redd::Clients::Base::Read

Methods that require the “read” scope

Public Instance Methods

from_fullname(*fnames) click to toggle source

@param [Array<String>] fnames A list of fullnames. @return [Objects::Listing<Objects::Thing>] A listing of things with

the fullname.
# File lib/redd/clients/base/read.rb, line 9
def from_fullname(*fnames)
  names = fnames.join(',')
  request_object(:get, '/api/info', id: names)
end
from_url(url) click to toggle source

@param [String] url The url of the thing. @return [Objects::Thing] The thing.

# File lib/redd/clients/base/read.rb, line 16
def from_url(url)
  request_object(:get, '/api/info', url: url).first
end
multi_from_path(path) click to toggle source

Fetch an individual multi from its path. @param [String] path The multi's path. @return [Objects::LabeledMulti]

# File lib/redd/clients/base/read.rb, line 41
def multi_from_path(path)
  # rubocop:disable Style/RegexpLiteral
  without_slash = path.gsub(/^\//, '')
  request_object(:get, '/api/multi/' + without_slash)
end
my_multis() click to toggle source

Fetch a list of multis belonging to the user.

# File lib/redd/clients/base/read.rb, line 33
def my_multis
  multis = get('/api/multi/mine').body
  multis.map { |thing| object_from_body(thing) }
end
subreddit_from_name(name) click to toggle source

@param [String] name The subreddit's display name. @return [Objects::Subreddit] The subreddit if found.

# File lib/redd/clients/base/read.rb, line 28
def subreddit_from_name(name)
  request_object(:get, "/r/#{name}/about.json")
end
user_from_name(name) click to toggle source

@param [String] name The username. @return [Objects::User] The user.

# File lib/redd/clients/base/read.rb, line 22
def user_from_name(name)
  request_object(:get, "/user/#{name}/about.json")
end