Class: Proxtopus::Proxy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, protocol, country, anonymity) ⇒ Proxy

Returns a new instance of Proxy.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/proxtopus/proxy.rb', line 6

def initialize(host, port, protocol, country, anonymity)
  @host = host.to_s.downcase
  @port = port.to_i
  @protocol = protocol.to_s.downcase
  @country = country.to_s
  if anonymity =~ /h(igh(ly)?)?\s*a(non(ymous)?)?\s*(p(roxy)?)?/ix
    @anonymity = 'HAP'
  elsif anonymity =~ /a(non(ymous)?)?\s*(p(roxy)?)?/ix
    @anonymity = 'AP'
  elsif anonymity =~ /t(rans(parent)?)?\s*(p(roxy)?)?/ix
    @anonymity = 'TP'
  else
    puts "Invalid anonymity '#{anonymity}'... ignoring."
    @anonymity = nil
  end
  
  #puts "[Initialized Proxy]"
  #puts "#{@procotol}://#{@host}:#{@port} w/ #{@anonymity},#{@country}"
  #puts
  #puts
end

Instance Attribute Details

#anonymityObject

Returns the value of attribute anonymity.



4
5
6
# File 'lib/proxtopus/proxy.rb', line 4

def anonymity
  @anonymity
end

#countryObject

Returns the value of attribute country.



4
5
6
# File 'lib/proxtopus/proxy.rb', line 4

def country
  @country
end

#hostObject

Returns the value of attribute host.



4
5
6
# File 'lib/proxtopus/proxy.rb', line 4

def host
  @host
end

#portObject

Returns the value of attribute port.



4
5
6
# File 'lib/proxtopus/proxy.rb', line 4

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



4
5
6
# File 'lib/proxtopus/proxy.rb', line 4

def protocol
  @protocol
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/proxtopus/proxy.rb', line 28

def ==(other)
  if other.is_a?(Proxtopus::Proxy)
    if @host == other.host && @port == other.port && @protocol == other.protocol
      true
    else
      false
    end
  else
    false
  end
end