Sha256: 1200cb1a2bd94f2e20ff14db1fa2160108c22ce04ec10eeff47880f65cab8ef4

Contents?: true

Size: 732 Bytes

Versions: 6

Compression:

Stored size: 732 Bytes

Contents

require "forwardable"

module Redd
  module Object
    # A listing of various reddit things.
    # @see http://www.reddit.com/dev/api#listings
    # @see http://stackoverflow.com/a/2080118
    class Listing
      include Enumerable
      extend Forwardable
      def_delegators :@things, :[], :length, :size, :each, :map, :empty?

      # @!attribute [r] things
      # @return [Array] A list of things in the listing.
      attr_reader :things

      attr_reader :kind
      attr_reader :after
      attr_reader :before

      def initialize(listing)
        @kind = "Listing"
        @things = listing[:data][:children]
        @after = listing[:data][:after]
        @before = listing[:data][:before]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
redd-0.6.5 lib/redd/object/listing.rb
redd-0.6.4 lib/redd/object/listing.rb
redd-0.6.3 lib/redd/object/listing.rb
redd-0.6.2 lib/redd/object/listing.rb
redd-0.6.1 lib/redd/object/listing.rb
redd-0.6.0 lib/redd/object/listing.rb