Sha256: 903d8eb8fa061c2595710c4d8b7751c252d2b7314b4b96baebe3176ef533475b

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module Spidr
  #
  # @since 0.6.0
  #
  class Proxy < Struct.new(:host, :port, :user, :password)

    # Default port to use.
    DEFAULT_PORT = 8080

    #
    # Initializes the proxy.
    #
    # @param [Hash] attributes
    #   Attributes for the proxy.
    #
    # @option attributes [String] :host
    #   The host the proxy is running on.
    #
    # @option attributes [Integer] :port
    #   The port the proxy is running on.
    #
    # @option attributes [String] :user
    #   The user to authenticate as with the proxy.
    #
    # @option attributes [String] :password
    #   The password to authenticate with.
    #
    def initialize(attributes={})
      super(
        attributes[:host],
        attributes.fetch(:port,DEFAULT_PORT),
        attributes[:user],
        attributes[:password]
      )
    end

    #
    # Determines if the proxy settings are set.
    #
    # @return [Boolean]
    #
    def enabled?
      !host.nil?
    end

    #
    # Determines if the proxy is not set.
    #
    # @return [Boolean]
    #
    def disabled?
      host.nil?
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spidr-0.6.1 lib/spidr/proxy.rb
spidr-0.6.0 lib/spidr/proxy.rb