lib/fb_scrape/post.rb in fb_scrape-0.0.5 vs lib/fb_scrape/post.rb in fb_scrape-0.0.6

- old
+ new

@@ -27,16 +27,18 @@ def has_more_comments? @page_info && next_cursor end - def load_all_comments - while has_more_comments? do + def load_all_comments(limit=nil) + while has_more_comments? && is_below_limit?(limit) do load_more_comments end end + + def to_json(*args) JSON.pretty_generate({ id: @id, created_at: @created_at, message: @message, @@ -44,9 +46,13 @@ }) end private + + def is_below_limit?(limit) + is_below_limit = limit.nil? || @comments.length < limit + end def load_from_url url resp = HTTParty.get(url) case resp.code when 200