Sha256: 052f86abe2ea9cc5f7b674dbd22923c9f5aaf709e9c7b28f832b39d782956ca5

Contents?: true

Size: 645 Bytes

Versions: 1

Compression:

Stored size: 645 Bytes

Contents

# frozen_string_literal: true

require_relative 'basic_model'

module Redd
  module Models
    # A backward-expading listing of items.
    # @see Stream
    class Listing < BasicModel
      include Enumerable

      # Make a Listing from a basic Hash.
      # @return [Listing]
      def self.from_response(client, hash)
        hash[:children].map! { |el| client.unmarshal(el) }
        new(client, hash)
      end

      %i([] each empty? length size).each do |method_name|
        define_method(method_name) do |*args, &block|
          get_attribute(:children).public_send(method_name, *args, &block)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redd-0.8.0.pre.1 lib/redd/models/listing.rb