Class: RedditApi::Comment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Comment

Returns a new instance of Comment.



7
8
9
10
11
# File 'lib/reddit_api/comment.rb', line 7

def initialize(args = {})
  @reddit_id = args.fetch("id", nil)
  @author_name = args.fetch("author", nil)
  @subreddit_name = args.fetch("subreddit", nil)
end

Instance Attribute Details

#author_nameObject (readonly)

Returns the value of attribute author_name.



5
6
7
# File 'lib/reddit_api/comment.rb', line 5

def author_name
  @author_name
end

#reddit_idObject (readonly)

Returns the value of attribute reddit_id.



5
6
7
# File 'lib/reddit_api/comment.rb', line 5

def reddit_id
  @reddit_id
end

#subreddit_nameObject (readonly)

Returns the value of attribute subreddit_name.



5
6
7
# File 'lib/reddit_api/comment.rb', line 5

def subreddit_name
  @subreddit_name
end

Instance Method Details

#to_hObject



13
14
15
16
17
18
19
# File 'lib/reddit_api/comment.rb', line 13

def to_h
  {
    reddit_id: reddit_id,
    author_name: author_name,
    subreddit_name: subreddit_name
  }
end