Class: ProxyFetcher::Proxy
- Inherits:
-
Object
- Object
- ProxyFetcher::Proxy
- Defined in:
- lib/proxy_fetcher/proxy.rb
Constant Summary collapse
- TYPES =
[ HTTP = 'HTTP'.freeze, HTTPS = 'HTTPS'.freeze, SOCKS4 = 'SOCKS4'.freeze, SOCKS5 = 'SOCKS5'.freeze ].freeze
Instance Attribute Summary collapse
-
#addr ⇒ Object
Returns the value of attribute addr.
-
#anonymity ⇒ Object
Returns the value of attribute anonymity.
-
#country ⇒ Object
Returns the value of attribute country.
-
#port ⇒ Object
Returns the value of attribute port.
-
#response_time ⇒ Object
Returns the value of attribute response_time.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #connectable? ⇒ Boolean (also: #valid?)
-
#initialize(attributes = {}) ⇒ Proxy
constructor
A new instance of Proxy.
- #ssl? ⇒ Boolean
- #uri ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Proxy
Returns a new instance of Proxy.
22 23 24 25 26 |
# File 'lib/proxy_fetcher/proxy.rb', line 22 def initialize(attributes = {}) attributes.each do |attr, value| public_send("#{attr}=", value) end end |
Instance Attribute Details
#addr ⇒ Object
Returns the value of attribute addr.
3 4 5 |
# File 'lib/proxy_fetcher/proxy.rb', line 3 def addr @addr end |
#anonymity ⇒ Object
Returns the value of attribute anonymity.
3 4 5 |
# File 'lib/proxy_fetcher/proxy.rb', line 3 def anonymity @anonymity end |
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/proxy_fetcher/proxy.rb', line 3 def country @country end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/proxy_fetcher/proxy.rb', line 3 def port @port end |
#response_time ⇒ Object
Returns the value of attribute response_time.
3 4 5 |
# File 'lib/proxy_fetcher/proxy.rb', line 3 def response_time @response_time end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/proxy_fetcher/proxy.rb', line 3 def type @type end |
Instance Method Details
#connectable? ⇒ Boolean Also known as: valid?
28 29 30 |
# File 'lib/proxy_fetcher/proxy.rb', line 28 def connectable? ProxyFetcher.config.proxy_validator.connectable?(addr, port) end |
#ssl? ⇒ Boolean
18 19 20 |
# File 'lib/proxy_fetcher/proxy.rb', line 18 def ssl? https? || socks4? || socks5? end |
#uri ⇒ Object
34 35 36 |
# File 'lib/proxy_fetcher/proxy.rb', line 34 def uri URI::Generic.build(host: addr, port: port) end |
#url ⇒ Object
38 39 40 |
# File 'lib/proxy_fetcher/proxy.rb', line 38 def url "#{addr}:#{port}" end |