Class: Redd::Objects::Listing

Inherits:
Array
  • Object
show all
Defined in:
lib/redd/objects/listing.rb

Overview

A collection of reddit things.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, attributes) ⇒ Listing

TODO:

Only call Clients::Base#object_from_body when item is being accessed.

Returns a new instance of Listing.

Parameters:

  • client (Clients::Base)

    The client to expand the comments with.

  • attributes ({:before => String, :after => String, :children => Array<Hash>})

    The data to initialize the class with.



20
21
22
23
24
25
26
# File 'lib/redd/objects/listing.rb', line 20

def initialize(client, attributes)
  @before = attributes[:before]
  @after = attributes[:after]
  attributes[:children].each do |child|
    self << (client.object_from_body(child) || child)
  end
end

Instance Attribute Details

#afterString (readonly)

Returns The id of the object after the listing.

Returns:

  • (String)

    The id of the object after the listing.



12
13
14
# File 'lib/redd/objects/listing.rb', line 12

def after
  @after
end

#beforeString (readonly)

Returns The id of the object before the listing.

Returns:

  • (String)

    The id of the object before the listing.



8
9
10
# File 'lib/redd/objects/listing.rb', line 8

def before
  @before
end