Sha256: 47c502497c321a8293f2afd00e399a60606aa40a7a8f0d71468b166f8ca30877

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

Contents

module Redd
  module Client
    class Unauthenticated
      module Listing
        def by_id(*fullnames)
          names = fullnames.join(",")
          object_from_response :get,  "/by_id/#{names}.json"
        end

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

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

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

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

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

        private

        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
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redd-0.1.2 lib/redd/client/unauthenticated/listing.rb