Class: Ungulate::CurlHttp

Inherits:
Object
  • Object
show all
Defined in:
lib/ungulate/curl_http.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CurlHttp

Returns a new instance of CurlHttp.



5
6
7
8
# File 'lib/ungulate/curl_http.rb', line 5

def initialize(options = {})
  @easy = Curl::Easy
  @logger = options[:logger] || ::Logger.new($stdout)
end

Instance Method Details

#codeObject



21
22
23
# File 'lib/ungulate/curl_http.rb', line 21

def code
  @response.response_code
end

#get_body(url) ⇒ Object



10
11
12
13
# File 'lib/ungulate/curl_http.rb', line 10

def get_body(url)
  @logger.info "GET via HTTP: #{url}"
  @easy.http_get(url).body_str
end

#put(url) ⇒ Object



15
16
17
18
19
# File 'lib/ungulate/curl_http.rb', line 15

def put(url)
  @logger.info "PUT #{url}"
  @response = @easy.http_put(url, '')
  self
end