Class: Libgss::AssetRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/libgss/asset_request.rb

Constant Summary collapse

STATUS_PREPARING =
0
STATUS_SENDING =
1
STATUS_WAITING =
2
STATUS_RECEIVED =
3
STATUS_SUCCESS =
4
STATUS_ERROR =
5
STATUS_TIMEOUT =
6

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(httpclient, url, req_headers) ⇒ AssetRequest

コンストラクタ



16
17
18
19
20
21
22
# File 'lib/libgss/asset_request.rb', line 16

def initialize(httpclient, url, req_headers)
  @httpclient = httpclient
  @url = url
  @req_headers = req_headers
  @response_data = nil
  @status = STATUS_PREPARING
end

Instance Attribute Details

#req_headersObject (readonly)

Returns the value of attribute req_headers.



13
14
15
# File 'lib/libgss/asset_request.rb', line 13

def req_headers
  @req_headers
end

#response_dataObject (readonly)

Returns the value of attribute response_data.



13
14
15
# File 'lib/libgss/asset_request.rb', line 13

def response_data
  @response_data
end

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'lib/libgss/asset_request.rb', line 13

def status
  @status
end

#urlObject (readonly)

Returns the value of attribute url.



13
14
15
# File 'lib/libgss/asset_request.rb', line 13

def url
  @url
end

Instance Method Details

#send_request(&callback) ⇒ Object



24
25
26
27
28
# File 'lib/libgss/asset_request.rb', line 24

def send_request(&callback)
  res = @httpclient.get(url, nil, req_headers)
  @response_data = res.body
  callback.call(@response_data) if callback
end