Sha256: 9f568f9d3059ce602e10e6604eedf3926e0c096a238435ae0a1932493b261f72
Contents?: true
Size: 706 Bytes
Versions: 2
Compression:
Stored size: 706 Bytes
Contents
#encoding: UTF-8 require 'net/http' require 'uri' require 'openssl' module Termit class DataFetcher include CanOutput delegate :display_no_internet_msg, to: :output_manager def initialize url, text @url = url @text = text end def data send_request end private def send_request uri = URI.parse @url http = Net::HTTP.new(uri.host, uri.port) query = "q=#{URI::encode(@text)}" url = "#{uri.request_uri}&#{query}" request = Net::HTTP::Get.new(url) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.request(request) rescue SocketError display_no_internet_msg end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
termit-2.13.0 | lib/termit/data_fetcher.rb |
termit-2.12.1 | lib/termit/data_fetcher.rb |