Class: Clients::Proxy6Client

Inherits:
Object
  • Object
show all
Defined in:
lib/clients/proxy6_client.rb

Constant Summary collapse

API_URL =
"https://proxy6.net/api".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_url: API_URL, api_key: ENV["PROXY6_KEY"], ip_version: "4") ⇒ Proxy6Client

Returns a new instance of Proxy6Client.



10
11
12
13
14
15
16
17
18
19
# File 'lib/clients/proxy6_client.rb', line 10

def initialize(
  api_url: API_URL,
  api_key: ENV["PROXY6_KEY"],
  ip_version: "4"
)
  @api_url = api_url
  @api_key = api_key
  @ip_version = ip_version.to_s
  @proxy = fetch_proxy
end

Instance Attribute Details

#ip_versionObject (readonly)

Returns the value of attribute ip_version.



8
9
10
# File 'lib/clients/proxy6_client.rb', line 8

def ip_version
  @ip_version
end

Instance Method Details

#hostObject



21
22
23
# File 'lib/clients/proxy6_client.rb', line 21

def host
  @proxy["host"]
end

#passwordObject



33
34
35
# File 'lib/clients/proxy6_client.rb', line 33

def password
  @proxy["pass"]
end

#portObject



25
26
27
# File 'lib/clients/proxy6_client.rb', line 25

def port
  @proxy["port"].to_i
end

#reset!Object



41
42
43
# File 'lib/clients/proxy6_client.rb', line 41

def reset!
  @proxy = fetch_proxy
end

#to_sObject



37
38
39
# File 'lib/clients/proxy6_client.rb', line 37

def to_s
  [host, port, user, password].compact.join(":")
end

#userObject



29
30
31
# File 'lib/clients/proxy6_client.rb', line 29

def user
  @proxy["user"]
end