Class: Headsail::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/headsail/http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ HTTP

Returns a new instance of HTTP.



7
8
9
10
11
12
# File 'lib/headsail/http.rb', line 7

def initialize(api)
  @api = api
  @response = nil
  @oauth = determine_oauth
  @request = determine_request
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/headsail/http.rb', line 5

def response
  @response
end

Instance Method Details

#bodyObject



18
19
20
# File 'lib/headsail/http.rb', line 18

def body
  @response.body
end

#codeObject



22
23
24
# File 'lib/headsail/http.rb', line 22

def code
  @response.code
end

#code_statusObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/headsail/http.rb', line 26

def code_status
  case @response.code.to_i
  when 200 || 201
    :SUCCESS
  when (400..499)
    :BAD_REQUEST
  when (500..599)
    :SERVER_PROBLEMS
  end
end

#runObject



14
15
16
# File 'lib/headsail/http.rb', line 14

def run
  send(@request)
end