Class: Lobstersbot::RssReader
- Inherits:
-
Object
- Object
- Lobstersbot::RssReader
- 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
- #call(not_before) ⇒ Object
-
#initialize(endpoint, open_proc = URI.method(:open)) ⇒ RssReader
constructor
A new instance of RssReader.
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 |