Class: Laika::Blog

Inherits:
Object
  • Object
show all
Defined in:
lib/laika/blog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Blog

Returns a new instance of Blog.



9
10
11
12
# File 'lib/laika/blog.rb', line 9

def initialize(url)
  @url = url
  @seen_ids = []
end

Instance Attribute Details

#feedObject (readonly)

Returns the value of attribute feed.



7
8
9
# File 'lib/laika/blog.rb', line 7

def feed
  @feed
end

Instance Method Details

#get_new_entriesObject



14
15
16
17
18
19
20
# File 'lib/laika/blog.rb', line 14

def get_new_entries
  @feed = FeedNormalizer::FeedNormalizer.parse(open(@url))
  feed_ids = @feed.entries.collect{|e| e.id}
  new_ids = feed_ids - @seen_ids
  @seen_ids += new_ids
  @feed.entries.select{|e| new_ids.include?(e.id)}
end