Class: WebPageParser::GuardianPageParserFactory
Constant Summary
collapse
- URL_RE =
ORegexp.new("(www\.)?guardian\.co\.uk/[a-z-]+(/[a-z-]+)?/[0-9]{4}/[a-z]{3}/[0-9]{1,2}/[a-z-]{5,200}$")
- INVALID_URL_RE =
ORegexp.new("/cartoon/|/commentisfree/poll/|/video/[0-9]+|/gallery/[0-9]+|/poll/[0-9]+")
Class Method Summary
collapse
add_factory, #can_parse?, #create, factories, inherited, load, parser_for
Class Method Details
.can_parse?(options) ⇒ Boolean
5
6
7
8
9
|
# File 'lib/web-page-parser/parsers/guardian_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/guardian_page_parser.rb', line 11
def self.create(options = {})
GuardianPageParserV1.new(options)
end
|