Class: RedditKit::Multireddit

Inherits:
Base
  • Object
show all
Includes:
Creatable
Defined in:
lib/redditkit/multireddit.rb

Overview

A class representing a multireddit.

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes

Instance Method Summary collapse

Methods included from Creatable

#created_at

Methods inherited from Base

#[], attr_reader, #initialize

Constructor Details

This class inherits a constructor from RedditKit::Base

Instance Attribute Details

#can_editObject (readonly) Also known as: editable?

Returns the value of attribute can_edit.



11
12
13
# File 'lib/redditkit/multireddit.rb', line 11

def can_edit
  @can_edit
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/redditkit/multireddit.rb', line 10

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/redditkit/multireddit.rb', line 13

def path
  @path
end

#visibilityObject (readonly)

Returns the value of attribute visibility.



12
13
14
# File 'lib/redditkit/multireddit.rb', line 12

def visibility
  @visibility
end

Instance Method Details

#subredditsArray<String>

An array of subreddit display names.

Returns:

  • (Array<String>)


20
21
22
# File 'lib/redditkit/multireddit.rb', line 20

def subreddits
  @subreddits ||= @attributes[:subreddits].map { |subreddit| subreddit[:name] }
end

#usernameString

The username of the multireddit’s owner.

Returns:

  • (String)

    The owner’s username.



27
28
29
# File 'lib/redditkit/multireddit.rb', line 27

def username
  @username ||= path[/\/user\/(.*)\/m\//, 1]
end