Class: WebStat::FetchAsWeb
- Defined in:
- lib/web_stat/fetch/fetch_as_web.rb
Instance Attribute Summary
Attributes inherited from Fetch
#html, #nokogiri, #url, #userdic
Instance Method Summary collapse
-
#initialize(url) ⇒ FetchAsWeb
constructor
initialize class.
-
#url_valid?(url) ⇒ Boolean
Validation url.
Methods inherited from Fetch
#content, #eyecatch_image_path, #get_url, #save_local_path, #site_name, #stat, #title
Constructor Details
#initialize(url) ⇒ FetchAsWeb
initialize class
7 8 9 10 11 12 13 14 |
# File 'lib/web_stat/fetch/fetch_as_web.rb', line 7 def initialize(url) unless url_valid?(url) raise WebStat::INVALID_URL, url end @url = original_url(url) @html = get_url(@url) @nokogiri = ::Nokogiri::HTML(@html) end |
Instance Method Details
#url_valid?(url) ⇒ Boolean
Validation url
17 18 19 20 |
# File 'lib/web_stat/fetch/fetch_as_web.rb', line 17 def url_valid?(url) regexp = Regexp.new("^https?://([a-zA-Z0-9][a-zA-Z0-9\\\-\.]{1,61}[a-zA-Z0-9])\\\.([a-zA-Z]{2,})(.*)?$", Regexp::IGNORECASE) regexp.match?(url) end |