Class: Html2rss::HtmlExtractor::DateExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/html_extractor/date_extractor.rb

Overview

Extracts the earliest date from an article_tag.

Class Method Summary collapse

Class Method Details

.call(article_tag) ⇒ DateTime?

Returns:

  • (DateTime, nil)


8
9
10
11
12
13
14
15
16
# File 'lib/html2rss/html_extractor/date_extractor.rb', line 8

def self.call()
  times = .css('[datetime]').filter_map do |tag|
    DateTime.parse(tag['datetime'])
  rescue ArgumentError, TypeError
    nil
  end

  times.min
end