Class: OpenGraphy::Uri::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/open_graphy/fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri_str, limit = 10) ⇒ Fetcher

Returns a new instance of Fetcher.



4
5
6
# File 'lib/open_graphy/fetcher.rb', line 4

def initialize(uri_str, limit = 10)
  @uri_str, @limit = uri_str, limit
end

Instance Method Details

#fetchObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/open_graphy/fetcher.rb', line 8

def fetch
  check_redirect_limit

  http_response = response
  case http_response
  when Net::HTTPSuccess then
    http_response
  when Net::HTTPRedirection then
    follow_redirection(http_response)
  else
    http_response.value
  end
end