Class: RedditApi::Post
- Inherits:
-
Object
- Object
- RedditApi::Post
- Defined in:
- lib/reddit_api/post.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#reddit_id ⇒ Object
readonly
Returns the value of attribute reddit_id.
-
#stickied ⇒ Object
readonly
Returns the value of attribute stickied.
-
#subreddit ⇒ Object
readonly
Returns the value of attribute subreddit.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Post
constructor
A new instance of Post.
- #to_h ⇒ Object
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
#author ⇒ Object (readonly)
Returns the value of attribute author.
5 6 7 |
# File 'lib/reddit_api/post.rb', line 5 def @author end |
#reddit_id ⇒ Object (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 |
#stickied ⇒ Object (readonly)
Returns the value of attribute stickied.
5 6 7 |
# File 'lib/reddit_api/post.rb', line 5 def stickied @stickied end |
#subreddit ⇒ Object (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_h ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/reddit_api/post.rb', line 14 def to_h { reddit_id: reddit_id, author: , subreddit: subreddit, stickied: stickied } end |