Sha256: 126556726fa0e7679382bab120d7a6a73a5283c1f8acdb700aa2dba293e917ab
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
module ProxyFetcher class Proxy attr_reader :addr, :port, :country, :response_time, :speed, :type, :anonymity def initialize(html_row) ProxyFetcher.config.provider.parse_entry(html_row, self) self end def connectable? connection = Net::HTTP.new(addr, port) connection.use_ssl = true if https? connection.open_timeout = ProxyFetcher.config.open_timeout connection.read_timeout = ProxyFetcher.config.read_timeout connection.start { |http| return true if http.request_head('/') } false rescue Timeout::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EOFError false end alias valid? connectable? %i[slow medium fast].each do |method| define_method "#{method}?" do speed == method end end def http? type.casecmp('http').zero? end def https? type.casecmp('https').zero? end def uri URI::Generic.build(host: addr, port: port, scheme: type) end def url uri.to_s end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
proxy_fetcher-0.2.3 | lib/proxy_fetcher/proxy.rb |
proxy_fetcher-0.2.2 | lib/proxy_fetcher/proxy.rb |
proxy_fetcher-0.2.1 | lib/proxy_fetcher/proxy.rb |