Class: UrlExpander::Expanders::Simurl
- Defined in:
- lib/url_expander/expanders/scrape/simurl.rb
Overview
Expand simurl.com/ URLS Usage: UrlExpander::Client.expand(“simurl.com/fendaz”)
Defined Under Namespace
Classes: Request
Constant Summary collapse
- PATTERN =
%r'(http://simurl\.com(/[\w/]+))'
Instance Attribute Summary collapse
-
#parent_klass ⇒ Object
readonly
Returns the value of attribute parent_klass.
Attributes inherited from Scrape
Class Method Summary collapse
-
.scrape_url(html) ⇒ Object
How to scarpe the url from a Qsr.li html document.
Instance Method Summary collapse
-
#initialize(short_url = "", options = {}) ⇒ Simurl
constructor
A new instance of Simurl.
Constructor Details
#initialize(short_url = "", options = {}) ⇒ Simurl
Returns a new instance of Simurl.
12 13 14 15 |
# File 'lib/url_expander/expanders/scrape/simurl.rb', line 12 def initialize(short_url="", ={}) @parent_klass = self.class super(short_url, ) end |
Instance Attribute Details
#parent_klass ⇒ Object (readonly)
Returns the value of attribute parent_klass.
10 11 12 |
# File 'lib/url_expander/expanders/scrape/simurl.rb', line 10 def parent_klass @parent_klass end |
Class Method Details
.scrape_url(html) ⇒ Object
How to scarpe the url from a Qsr.li html document
18 19 20 21 22 23 24 25 26 |
# File 'lib/url_expander/expanders/scrape/simurl.rb', line 18 def self.scrape_url(html) doc = Hpricot(html) str = doc.at("meta").attributes['content'] start_slice = str.index("=") +1 end_slice = str.size - start_slice url = str.slice(start_slice, end_slice) raise UrlExpander::Error.new('page not found',404) if url == "/index.php" url end |