Class: MechanizeContent::Util
- Inherits:
-
Object
- Object
- MechanizeContent::Util
- Defined in:
- lib/mechanize-content/util.rb
Constant Summary collapse
- MIN_WIDTH =
64
- MIN_HEIGHT =
64
- AD_WIDTH =
728
- AD_HEIGHT =
90
Class Method Summary collapse
- .build_absolute_url(current_src, url) ⇒ Object
- .get_base_url(doc, url) ⇒ Object
- .valid_image?(width, height, src) ⇒ Boolean
Class Method Details
.build_absolute_url(current_src, url) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/mechanize-content/util.rb', line 19 def self.build_absolute_url(current_src, url) if URI.parse(current_src).relative? current_src = (URI.parse(url.to_s)+current_src).to_s end current_src end |
.get_base_url(doc, url) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/mechanize-content/util.rb', line 10 def self.get_base_url(doc, url) base_url = doc.xpath("//base/@href").first if base_url.nil? return url else return base_url.value end end |
.valid_image?(width, height, src) ⇒ Boolean
26 27 28 29 30 31 32 33 |
# File 'lib/mechanize-content/util.rb', line 26 def self.valid_image?(width, height, src) if width > MIN_WIDTH && height > MIN_HEIGHT && !src.include?("banner") && !src.include?(".gif") if (!(width == AD_WIDTH) && !(height == AD_HEIGHT)) return true end end return false end |