Class: RedditApi::Subreddit
- Inherits:
-
Object
- Object
- RedditApi::Subreddit
- Defined in:
- lib/reddit_api/subreddit.rb
Instance Attribute Summary collapse
-
#active_users ⇒ Object
readonly
Returns the value of attribute active_users.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nsfw ⇒ Object
readonly
Returns the value of attribute nsfw.
-
#reddit_id ⇒ Object
readonly
Returns the value of attribute reddit_id.
-
#subscriber_count ⇒ Object
readonly
Returns the value of attribute subscriber_count.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Subreddit
constructor
A new instance of Subreddit.
- #to_h ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Subreddit
Returns a new instance of Subreddit.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/reddit_api/subreddit.rb', line 7 def initialize(args = {}) @reddit_id = args.fetch("id", nil) @name = args.fetch("display_name", nil) @url = args.fetch("url", nil) @description = args.fetch("public_description", nil) @subscriber_count = args.fetch("subscribers", nil) @icon = args.fetch("header_img", nil) @category = args.fetch("advertiser_category", nil) @active_users = args.fetch("accounts_active", nil) @nsfw = args.fetch("over18", nil) end |
Instance Attribute Details
#active_users ⇒ Object (readonly)
Returns the value of attribute active_users.
4 5 6 |
# File 'lib/reddit_api/subreddit.rb', line 4 def active_users @active_users end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
4 5 6 |
# File 'lib/reddit_api/subreddit.rb', line 4 def category @category end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/reddit_api/subreddit.rb', line 4 def description @description end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
4 5 6 |
# File 'lib/reddit_api/subreddit.rb', line 4 def icon @icon end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/reddit_api/subreddit.rb', line 4 def name @name end |
#nsfw ⇒ Object (readonly)
Returns the value of attribute nsfw.
4 5 6 |
# File 'lib/reddit_api/subreddit.rb', line 4 def nsfw @nsfw end |
#reddit_id ⇒ Object (readonly)
Returns the value of attribute reddit_id.
4 5 6 |
# File 'lib/reddit_api/subreddit.rb', line 4 def reddit_id @reddit_id end |
#subscriber_count ⇒ Object (readonly)
Returns the value of attribute subscriber_count.
4 5 6 |
# File 'lib/reddit_api/subreddit.rb', line 4 def subscriber_count @subscriber_count end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/reddit_api/subreddit.rb', line 4 def url @url end |
Instance Method Details
#to_h ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/reddit_api/subreddit.rb', line 19 def to_h { reddit_id: reddit_id, name: name, url: url, description: description, subscriber_count: subscriber_count, icon: icon, category: category, active_users: active_users, nsfw: nsfw } end |