Module: Snooby::Comments

Included in:
Post, Subreddit, User
Defined in:
lib/snooby/actions.rb

Instance Method Summary collapse

Instance Method Details

#comments(count = 25) ⇒ Object

Returns an array of structs containing the calling object’s comments. TODO: return more than just top-level comments for posts.



21
22
23
24
25
26
# File 'lib/snooby/actions.rb', line 21

def comments(count = 25)
  # @name suffices for users and subreddits, but a post's name is obtained
  # from its struct; the "t3_" must be removed before making the API call.
  @name ||= self.name[3..-1]
  Snooby.build(Comment, :"#{@kind}_comments", @name, count)
end