Class: Lobstersbot::RssReader

Inherits:
Object
  • Object
show all
Defined in:
lib/lobstersbot/rss_reader.rb

Constant Summary collapse

FORMAT =
'%s %s (%s) - %s'.freeze
USERNAME_REGXP =

rubocop:disable Style/MutableConstant, Lint/RedundantCopDisableDirective

/\((?<username>.+)\)/i

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, open_proc = URI.method(:open)) ⇒ RssReader

Returns a new instance of RssReader.



9
10
11
12
# File 'lib/lobstersbot/rss_reader.rb', line 9

def initialize(endpoint, open_proc = URI.method(:open))
  @endpoint = endpoint
  @open = open_proc
end

Instance Method Details

#call(not_before) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/lobstersbot/rss_reader.rb', line 14

def call(not_before)
  feed = @open.call(@endpoint)
  rss =  RSS::Parser.parse(feed)

  rss.items.map do |item|
    item.pubDate.to_i > not_before ? format_item(item) : nil
  end.compact
end