Class: WebPageParser::RTPageParserFactory

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

Constant Summary collapse

URL_RE =
ORegexp.new("(www\.)?rt\.com/[^/]+/[0-9]+-.*$")
INVALID_URL_RE =
ORegexp.new("/(in-vision|in-motion)/")

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
9
# File 'lib/web-page-parser/parsers/rt_page_parser.rb', line 5

def self.can_parse?(options)
  url = options[:url].split('#').first
  return nil if INVALID_URL_RE.match(url)
  URL_RE.match(url)
end

.create(options = {}) ⇒ Object



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

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