Class: HideMyAss::Proxy::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hidemyass/proxy/base.rb

Overview

Interface for the attributes of each proxy. Such attributes include the ip, port and protocol.

Examples:

Get the proxy’s ip address.

proxy.ip
# => '178.22.148.122'

Get the proxy’s port.

proxy.port
# => 3129

Get the proxy’s protocol.

proxy.protocol
# => 'HTTPS'

Get the hosted country.

proxy.country
# => 'FRANCE'

Get the complete url.

proxy.url
# => 'https://178.22.148.122:3129'

Direct Known Subclasses

HideMe, Hidester

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ HideMyAss::Proxy::Base

Initializes the proxy instance by passing a single row of the fetched result list. All attribute readers are lazy implemented.

Parameters:

  • row (Object)

    Pre-parsed row element.



33
34
35
# File 'lib/hidemyass/proxy/base.rb', line 33

def initialize(row)
  @row = row
end

Instance Attribute Details

#rowObject (readonly)

Raw data of the row element.

Returns:

  • (Object)


40
41
42
# File 'lib/hidemyass/proxy/base.rb', line 40

def row
  @row
end

Instance Method Details

#anonym?Boolean

If the proxy’s anonymity is high or even higher.

Returns:

  • (Boolean)


95
96
97
# File 'lib/hidemyass/proxy/base.rb', line 95

def anonym?
  anonymity.start_with? 'high'
end

#http?Boolean

If the proxy’s network protocol is HTTP.

Returns:

  • (Boolean)


67
68
69
# File 'lib/hidemyass/proxy/base.rb', line 67

def http?
  protocol == 'http'
end

#https?Boolean

If the proxy’s network protocol is HTTPS.

Returns:

  • (Boolean)


74
75
76
# File 'lib/hidemyass/proxy/base.rb', line 74

def https?
  protocol == 'https'
end

#inspectString

Custom inspect method.

> ‘<HideMyAss::Proxy 123.57.52.171:80>’

:nocov:

Examples:

inspect

Returns:

  • (String)


114
115
116
# File 'lib/hidemyass/proxy/base.rb', line 114

def inspect
  "<#{self.class.name} #{url}>"
end

#protocolString

The network protocol in in downcase letters. (https or http or socks)

Returns:

  • (String)


46
47
48
# File 'lib/hidemyass/proxy/base.rb', line 46

def protocol
  type
end

#rel_urlString

The relative URL without the leading protocol.

Returns:

  • (String)


53
54
55
# File 'lib/hidemyass/proxy/base.rb', line 53

def rel_url
  "#{ip}:#{port}"
end

#secure?Boolean

If the proxy’s anonymity is at least high and protocol is encrypted.

Returns:

  • (Boolean)


102
103
104
# File 'lib/hidemyass/proxy/base.rb', line 102

def secure?
  anonym? && ssl?
end

#socks?Boolean

If the proxy’s network protocol is SOCKS.

Returns:

  • (Boolean)


81
82
83
# File 'lib/hidemyass/proxy/base.rb', line 81

def socks?
  protocol.start_with? 'socks'
end

#ssl?Boolean

If the proxy supports SSL encryption.

Returns:

  • (Boolean)


88
89
90
# File 'lib/hidemyass/proxy/base.rb', line 88

def ssl?
  https? || socks?
end

#urlString

The complete URL of that proxy server.

Returns:

  • (String)


60
61
62
# File 'lib/hidemyass/proxy/base.rb', line 60

def url
  "#{protocol}://#{rel_url}"
end