Class: WWW::Favicon
- Inherits:
-
Object
- Object
- WWW::Favicon
- Defined in:
- lib/www/favicon.rb
Constant Summary collapse
- VERSION =
'0.0.6'
Instance Method Summary collapse
Instance Method Details
#find(url) ⇒ Object
10 11 12 13 |
# File 'lib/www/favicon.rb', line 10 def find(url) response = request(url) find_from_html(response.body, response.request_url) end |
#find_from_html(html, url) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/www/favicon.rb', line 15 def find_from_html(html, url) favicon_url = find_from_link(html, url) || default_path(url) return nil unless valid_favicon_url?(favicon_url) favicon_url end |
#valid_favicon_url?(url) ⇒ Boolean
23 24 25 26 27 28 29 30 31 |
# File 'lib/www/favicon.rb', line 23 def valid_favicon_url?(url) response = request(url) ( response.code =~ /\A2/ && response.body.to_s != '' && response.content_type =~ /image/i ) ? true : false end |