Class: BaconIpsum::HttpClient
- Inherits:
-
Object
- Object
- BaconIpsum::HttpClient
- Defined in:
- lib/bacon_ipsum/http_client.rb
Overview
http client for requests to bacon ipsum api
Constant Summary collapse
- BASE_ENDPOINT =
'https://baconipsum.com/api/'- REQUEST_TIMEOUT =
30
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#paras ⇒ Object
Returns the value of attribute paras.
-
#sentences ⇒ Object
Returns the value of attribute sentences.
-
#start_with_lorem ⇒ Object
Returns the value of attribute start_with_lorem.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(paras, sentences, type, start_with_lorem, format) ⇒ HttpClient
constructor
A new instance of HttpClient.
Constructor Details
#initialize(paras, sentences, type, start_with_lorem, format) ⇒ HttpClient
13 14 15 16 17 18 19 |
# File 'lib/bacon_ipsum/http_client.rb', line 13 def initialize(paras, sentences, type, start_with_lorem, format) @paras = paras @sentences = sentences @type = type @start_with_lorem = start_with_lorem @format = format end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
11 12 13 |
# File 'lib/bacon_ipsum/http_client.rb', line 11 def format @format end |
#paras ⇒ Object
Returns the value of attribute paras.
11 12 13 |
# File 'lib/bacon_ipsum/http_client.rb', line 11 def paras @paras end |
#sentences ⇒ Object
Returns the value of attribute sentences.
11 12 13 |
# File 'lib/bacon_ipsum/http_client.rb', line 11 def sentences @sentences end |
#start_with_lorem ⇒ Object
Returns the value of attribute start_with_lorem.
11 12 13 |
# File 'lib/bacon_ipsum/http_client.rb', line 11 def start_with_lorem @start_with_lorem end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/bacon_ipsum/http_client.rb', line 11 def type @type end |
Instance Method Details
#get ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bacon_ipsum/http_client.rb', line 21 def get response = Typhoeus.get( BASE_ENDPOINT, params: params, timeout: REQUEST_TIMEOUT ) raise 'BaconFail' unless response.success? response.body end |