Module: Snooby::Comments

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

Instance Method Summary collapse

Instance Method Details

#comments(count = @kind == 'post' ? 500 : 25) ⇒ Object

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



23
24
25
26
27
28
# File 'lib/snooby/actions.rb', line 23

def comments(count = @kind == 'post' ? 500 : 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