Class: OpenGraphy::Url
- Inherits:
-
Object
- Object
- OpenGraphy::Url
- Defined in:
- lib/open_graphy/url.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(uri) ⇒ Url
constructor
A new instance of Url.
Constructor Details
#initialize(uri) ⇒ Url
Returns a new instance of Url.
3 4 5 |
# File 'lib/open_graphy/url.rb', line 3 def initialize(uri) @uri = uri end |
Class Method Details
.fetch(uri) ⇒ Object
7 8 9 |
# File 'lib/open_graphy/url.rb', line 7 def self.fetch(uri) new(uri).fetch end |
Instance Method Details
#fetch ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/open_graphy/url.rb', line 11 def fetch data.add('url', @uri) begin .each { |tag| data.add(tag.name, tag.value, namespace: tag.namespace) } data.add('__html_title_tag', doc.css('title').text) rescue SocketError, Net::HTTPServerException, Uri::RedirectLoopError, Uri::BadUriError end data end |