Class: WebPageParser::NewYorkTimesPageParserFactory

Inherits:
ParserFactory
  • Object
show all
Defined in:
lib/web-page-parser/parsers/new_york_times_page_parser.rb

Constant Summary collapse

URL_RE =
ORegexp.new("www\.nytimes\.com/[0-9]{4}/[0-9]{2}/[0-9]{2}/.+")
INVALID_URL_RE =
ORegexp.new("/cartoon/")

Class Method Summary collapse

Methods inherited from ParserFactory

add_factory, #can_parse?, #create, factories, inherited, load, parser_for

Class Method Details

.can_parse?(options) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
# File 'lib/web-page-parser/parsers/new_york_times_page_parser.rb', line 5

def self.can_parse?(options)
  return nil if INVALID_URL_RE.match(options[:url])
  URL_RE.match(options[:url])
end

.create(options = {}) ⇒ Object



10
11
12
# File 'lib/web-page-parser/parsers/new_york_times_page_parser.rb', line 10

def self.create(options = {})
  NewYorkTimesPageParserV2.new(options)
end