Class: Pastie::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/pastie-api/request.rb

Class Method Summary collapse

Class Method Details

.fetch(link) ⇒ Object

Returns response body of specified link



4
5
6
7
8
9
10
# File 'lib/pastie-api/request.rb', line 4

def self.fetch(link)
  url = URI.parse(link)
  resp = Net::HTTP.start(url.host, url.port) do |http|
    http.get(url.path + "?" + url.query.to_s)
  end
  return resp.body if resp.kind_of?(Net::HTTPOK)
end