Class: RedditApi::Post

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Post

Returns a new instance of Post.



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

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

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



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

def author
  @author
end

#reddit_idObject (readonly)

Returns the value of attribute reddit_id.



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

def reddit_id
  @reddit_id
end

#stickiedObject (readonly)

Returns the value of attribute stickied.



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

def stickied
  @stickied
end

#subredditObject (readonly)

Returns the value of attribute subreddit.



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

def subreddit
  @subreddit
end

Instance Method Details

#to_hObject



14
15
16
17
18
19
20
21
# File 'lib/reddit_api/post.rb', line 14

def to_h
  {
    reddit_id: reddit_id,
    author: author,
    subreddit: subreddit,
    stickied: stickied
  }
end