class ProxyFetcher::Proxy
Proxy
object
Constants
- TYPES
Proxy
types
Attributes
addr[RW]
@!attribute [rw] addr
@return [String] address (IP or domain)
anonymity[RW]
@!attribute [rw] anonymity
@return [String] anonymity level (high, elite, transparent, etc)
country[RW]
@!attribute [rw] country
@return [String] country or country code
port[RW]
@!attribute [rw] port
@return [Integer] port
response_time[RW]
@!attribute [rw] response_time
@return [Integer] response time (value and measurements depends on the provider)
type[RW]
@!attribute [rw] type
@return [String] type (SOCKS, HTTP(S))
Public Class Methods
new(attributes = {})
click to toggle source
Initialize new Proxy
@param attributes [Hash]
proxy attributes
@return [Proxy]
# File lib/proxy_fetcher/proxy.rb, line 65 def initialize(attributes = {}) attributes.each do |attr, value| public_send("#{attr}=", value) end end
Public Instance Methods
==(other)
click to toggle source
# File lib/proxy_fetcher/proxy.rb, line 108 def ==(other) other.is_a?(Proxy) && addr == other.addr && port == other.port end
connectable?()
click to toggle source
Checks if proxy object is connectable (can be used as a proxy for HTTP requests).
@return [Boolean]
true if proxy connectable, otherwise false.
# File lib/proxy_fetcher/proxy.rb, line 77 def connectable? ProxyFetcher.config.proxy_validator.connectable?(addr, port) end
Also aliased as: valid?
eql?(other)
click to toggle source
# File lib/proxy_fetcher/proxy.rb, line 112 def eql?(other) hash.eql?(other.hash) end
hash()
click to toggle source
# File lib/proxy_fetcher/proxy.rb, line 116 def hash [addr.hash, port.hash].hash end
ssl?()
click to toggle source
Returns true if proxy is secure (works through https, socks4 or socks5).
@return [Boolean]
true if proxy is secure, otherwise false.
# File lib/proxy_fetcher/proxy.rb, line 54 def ssl? https? || socks4? || socks5? end
uri()
click to toggle source
Returns URI::Generic
object with host and port values of the proxy.
@return [URI::Generic]
URI object.
# File lib/proxy_fetcher/proxy.rb, line 88 def uri URI::Generic.build(host: addr, port: port) end
url(scheme: false)
click to toggle source
Returns String
object with addr:port values of the proxy.
@param scheme [Boolean]
Indicates if URL must include proxy type
@return [String]
true if proxy connectable, otherwise false.
# File lib/proxy_fetcher/proxy.rb, line 100 def url(scheme: false) if scheme URI::Generic.build(scheme: type, host: addr, port: port).to_s else URI::Generic.build(host: addr, port: port).to_s end end