Class: Spidr::Proxy

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

Overview

Since:

  • 0.6.0

Constant Summary collapse

DEFAULT_PORT =

Default port to use.

Since:

  • 0.6.0

8080

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Proxy

Initializes the proxy.

Parameters:

  • attributes (Hash) (defaults to: {})

    Attributes for the proxy.

Options Hash (attributes):

  • :host (String)

    The host the proxy is running on.

  • :port (Integer)

    The port the proxy is running on.

  • :user (String)

    The user to authenticate as with the proxy.

  • :password (String)

    The password to authenticate with.

Since:

  • 0.6.0


28
29
30
31
32
33
34
35
# File 'lib/spidr/proxy.rb', line 28

def initialize(attributes={})
  super(
    attributes[:host],
    attributes.fetch(:port,DEFAULT_PORT),
    attributes[:user],
    attributes[:password]
  )
end

Instance Attribute Details

#hostObject

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host


5
6
7
# File 'lib/spidr/proxy.rb', line 5

def host
  @host
end

#passwordObject

Returns the value of attribute password

Returns:

  • (Object)

    the current value of password


5
6
7
# File 'lib/spidr/proxy.rb', line 5

def password
  @password
end

#portObject

Returns the value of attribute port

Returns:

  • (Object)

    the current value of port


5
6
7
# File 'lib/spidr/proxy.rb', line 5

def port
  @port
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user


5
6
7
# File 'lib/spidr/proxy.rb', line 5

def user
  @user
end

Instance Method Details

#disabled?Boolean

Determines if the proxy is not set.

Returns:

  • (Boolean)

Since:

  • 0.6.0


51
52
53
# File 'lib/spidr/proxy.rb', line 51

def disabled?
  host.nil?
end

#enabled?Boolean

Determines if the proxy settings are set.

Returns:

  • (Boolean)

Since:

  • 0.6.0


42
43
44
# File 'lib/spidr/proxy.rb', line 42

def enabled?
  !host.nil?
end