Class: Redd::Models::Multireddit
- Defined in:
- lib/redd/models/multireddit.rb
Overview
A multi.
Instance Attribute Summary collapse
-
#can_edit? ⇒ Boolean
readonly
Whether the user can edit the multireddit.
-
#copied_from ⇒ Multireddit?
readonly
The multi this one was copied from.
-
#created_at ⇒ Time
readonly
The creation time.
-
#description_html ⇒ String
readonly
The html-rendered description.
-
#description_md ⇒ String
readonly
The markdown verion of the description.
-
#display_name ⇒ String
readonly
The multi's display name.
-
#icon_name ⇒ String
readonly
The icon name.
-
#icon_url ⇒ String?
readonly
The icon url.
-
#key_color ⇒ String
readonly
A hex color.
-
#name ⇒ String
readonly
The multireddit name.
-
#path ⇒ String
readonly
The multi path.
-
#subreddits ⇒ Array<Subreddit>
readonly
The subreddits in this multi.
-
#visibility ⇒ String
readonly
The multi visibility, either “public” or “private”.
- #weighting_scheme ⇒ String readonly
Attributes inherited from Model
Instance Method Summary collapse
- #comments(**params) ⇒ Object
- #controversial(**params) ⇒ Object
- #gilded(**params) ⇒ Object
- #hot(**params) ⇒ Object
-
#listing(sort, **params) ⇒ Listing<Submission>
Get the appropriate listing.
- #new(**params) ⇒ Object
- #rising(**params) ⇒ Object
- #top(**params) ⇒ Object
Methods inherited from Model
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.
42 |
# File 'lib/redd/models/multireddit.rb', line 42 property :can_edit?, from: :can_edit |
#copied_from ⇒ Multireddit? (readonly)
Returns 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_at ⇒ Time (readonly)
Returns the creation time.
75 |
# File 'lib/redd/models/multireddit.rb', line 75 property :created_at, from: :created_utc, with: ->(t) { Time.at(t) } |
#description_html ⇒ String (readonly)
Returns the html-rendered description.
58 |
# File 'lib/redd/models/multireddit.rb', line 58 property :description_html |
#description_md ⇒ String (readonly)
Returns the markdown verion of the description.
54 |
# File 'lib/redd/models/multireddit.rb', line 54 property :description_md |
#display_name ⇒ String (readonly)
Returns the multi's display name.
46 |
# File 'lib/redd/models/multireddit.rb', line 46 property :display_name |
#icon_name ⇒ String (readonly)
Returns the icon name.
87 |
# File 'lib/redd/models/multireddit.rb', line 87 property :icon_name |
#icon_url ⇒ String? (readonly)
Returns the icon url.
66 |
# File 'lib/redd/models/multireddit.rb', line 66 property :icon_url |
#key_color ⇒ String (readonly)
Returns a hex color.
79 |
# File 'lib/redd/models/multireddit.rb', line 79 property :key_color |
#name ⇒ String (readonly)
Returns the multireddit name.
50 |
# File 'lib/redd/models/multireddit.rb', line 50 property :name |
#path ⇒ String (readonly)
Returns the multi path.
95 |
# File 'lib/redd/models/multireddit.rb', line 95 property :path, :required |
#subreddits ⇒ Array<Subreddit> (readonly)
Returns 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)) } } |
#visibility ⇒ String (readonly)
Returns the multi visibility, either “public” or “private”.
83 |
# File 'lib/redd/models/multireddit.rb', line 83 property :visibility |
#weighting_scheme ⇒ String (readonly)
91 |
# File 'lib/redd/models/multireddit.rb', line 91 property :weighting_scheme |
Instance Method Details
#comments(**params) ⇒ Object
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
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
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
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>
The option :time only applies to the top and controversial sorts.
Get the appropriate listing.
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
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
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
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 |