Class: Redd::Models::Multireddit

Inherits:
Model
  • Object
show all
Defined in:
lib/redd/models/multireddit.rb

Overview

A multi.

Instance Attribute Summary collapse

Attributes inherited from Model

#client

Instance Method Summary collapse

Methods inherited from Model

#initialize

Constructor Details

This class inherits a constructor from Redd::Models::Model

Instance Attribute Details

#can_edit?Boolean (readonly)

Returns whether the user can edit the multireddit.

Returns:

  • (Boolean)

    whether the user can edit the multireddit


42
# File 'lib/redd/models/multireddit.rb', line 42

property :can_edit?, from: :can_edit

#copied_fromMultireddit? (readonly)

Returns the multi this one was copied from.

Returns:

  • (Multireddit, nil)

    the multi this one was copied from


62
# File 'lib/redd/models/multireddit.rb', line 62

property :copied_from, with: ->(n) { Multireddit.new(client, path: n) if n }

#created_atTime (readonly)

Returns the creation time.

Returns:

  • (Time)

    the creation time


75
# File 'lib/redd/models/multireddit.rb', line 75

property :created_at, from: :created_utc, with: ->(t) { Time.at(t) }

#description_htmlString (readonly)

Returns the html-rendered description.

Returns:

  • (String)

    the html-rendered description


58
# File 'lib/redd/models/multireddit.rb', line 58

property :description_html

#description_mdString (readonly)

Returns the markdown verion of the description.

Returns:

  • (String)

    the markdown verion of the description


54
# File 'lib/redd/models/multireddit.rb', line 54

property :description_md

#display_nameString (readonly)

Returns the multi's display name.

Returns:

  • (String)

    the multi's display name


46
# File 'lib/redd/models/multireddit.rb', line 46

property :display_name

#icon_nameString (readonly)

Returns the icon name.

Returns:

  • (String)

    the icon name


87
# File 'lib/redd/models/multireddit.rb', line 87

property :icon_name

#icon_urlString? (readonly)

Returns the icon url.

Returns:

  • (String, nil)

    the icon url


66
# File 'lib/redd/models/multireddit.rb', line 66

property :icon_url

#key_colorString (readonly)

Returns a hex color.

Returns:

  • (String)

    a hex color


79
# File 'lib/redd/models/multireddit.rb', line 79

property :key_color

#nameString (readonly)

Returns the multireddit name.

Returns:

  • (String)

    the multireddit name


50
# File 'lib/redd/models/multireddit.rb', line 50

property :name

#pathString (readonly)

Returns the multi path.

Returns:

  • (String)

    the multi path


95
# File 'lib/redd/models/multireddit.rb', line 95

property :path, :required

#subredditsArray<Subreddit> (readonly)

Returns the subreddits in this multi.

Returns:

  • (Array<Subreddit>)

    the subreddits in this multi


70
71
# File 'lib/redd/models/multireddit.rb', line 70

property :subreddits,
with: ->(a) { a.map { |n| Subreddit.new(client, display_name: n.fetch(:name)) } }

#visibilityString (readonly)

Returns the multi visibility, either “public” or “private”.

Returns:

  • (String)

    the multi visibility, either “public” or “private”


83
# File 'lib/redd/models/multireddit.rb', line 83

property :visibility

#weighting_schemeString (readonly)

Returns:

  • (String)

91
# File 'lib/redd/models/multireddit.rb', line 91

property :weighting_scheme

Instance Method Details

#comments(**params) ⇒ Object

See Also:


36
37
38
# File 'lib/redd/models/multireddit.rb', line 36

%i[hot new top controversial comments rising gilded].each do |sort|
  define_method(sort) { |**params| listing(sort, **params) }
end

#controversial(**params) ⇒ Object

See Also:


36
37
38
# File 'lib/redd/models/multireddit.rb', line 36

%i[hot new top controversial comments rising gilded].each do |sort|
  define_method(sort) { |**params| listing(sort, **params) }
end

#gilded(**params) ⇒ Object

See Also:


36
37
38
# File 'lib/redd/models/multireddit.rb', line 36

%i[hot new top controversial comments rising gilded].each do |sort|
  define_method(sort) { |**params| listing(sort, **params) }
end

#hot(**params) ⇒ Object

See Also:


36
37
38
# File 'lib/redd/models/multireddit.rb', line 36

%i[hot new top controversial comments rising gilded].each do |sort|
  define_method(sort) { |**params| listing(sort, **params) }
end

#listing(sort, **params) ⇒ Listing<Submission>

Note:

The option :time only applies to the top and controversial sorts.

Get the appropriate listing.

Parameters:

  • sort (:hot, :new, :top, :controversial, :comments, :rising, :gilded)

    the type of listing

  • params (Hash)

    a list of params to send with the request

Options Hash (**params):

  • :after (String)

    return results after the given fullname

  • :before (String)

    return results before the given fullname

  • :count (Integer)

    the number of items already seen in the listing

  • :limit (1..100)

    the maximum number of things to return

  • :time (:hour, :day, :week, :month, :year, :all)

    the time period to consider when sorting.

Returns:


22
23
24
25
# File 'lib/redd/models/multireddit.rb', line 22

def listing(sort, **params)
  params[:t] = params.delete(:time) if params.key?(:time)
  client.model(:get, "#{read_attribute(:path)}#{sort}", params)
end

#new(**params) ⇒ Object

See Also:


36
37
38
# File 'lib/redd/models/multireddit.rb', line 36

%i[hot new top controversial comments rising gilded].each do |sort|
  define_method(sort) { |**params| listing(sort, **params) }
end

#rising(**params) ⇒ Object

See Also:


36
37
38
# File 'lib/redd/models/multireddit.rb', line 36

%i[hot new top controversial comments rising gilded].each do |sort|
  define_method(sort) { |**params| listing(sort, **params) }
end

#top(**params) ⇒ Object

See Also:


36
37
38
# File 'lib/redd/models/multireddit.rb', line 36

%i[hot new top controversial comments rising gilded].each do |sort|
  define_method(sort) { |**params| listing(sort, **params) }
end