Class: RedditApi::Subreddit

Inherits:
Object
  • Object
show all
Defined in:
lib/reddit_api/subreddit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_usersObject (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

#categoryObject (readonly)

Returns the value of attribute category.



4
5
6
# File 'lib/reddit_api/subreddit.rb', line 4

def category
  @category
end

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/reddit_api/subreddit.rb', line 4

def description
  @description
end

#iconObject (readonly)

Returns the value of attribute icon.



4
5
6
# File 'lib/reddit_api/subreddit.rb', line 4

def icon
  @icon
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/reddit_api/subreddit.rb', line 4

def name
  @name
end

#nsfwObject (readonly)

Returns the value of attribute nsfw.



4
5
6
# File 'lib/reddit_api/subreddit.rb', line 4

def nsfw
  @nsfw
end

#reddit_idObject (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_countObject (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

#urlObject (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_hObject



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