Class: BingSearchClient::Client
- Inherits:
-
Object
- Object
- BingSearchClient::Client
- Defined in:
- lib/bing_search_client/client.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(url:) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(url:) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/bing_search_client/client.rb', line 5 def initialize(url:) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/bing_search_client/client.rb', line 3 def url @url end |
Instance Method Details
#get ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/bing_search_client/client.rb', line 9 def get uri = URI(url) req = Net::HTTP::Get.new(uri.request_uri) req.add_field('Ocp-Apim-Subscription-Key', BingSearchClient.config.account_key) response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http| http.request(req) end parse_response(response) end |