Module: Twog::BlogPostsHandler

Included in:
Twog
Defined in:
lib/twog/blog_posts_handler.rb

Instance Method Summary collapse

Instance Method Details

#get_new_blog_posts(posts, last_blog_post_tweeted) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/twog/blog_posts_handler.rb', line 5

def get_new_blog_posts(posts, last_blog_post_tweeted)
  return [] unless posts&.length&.positive?
  return posts unless last_blog_post_tweeted

  new_posts = posts.reject do |post|
    Time.parse(post.date.to_s) <= Time.parse(last_blog_post_tweeted.to_s)
  end
end