# Module: Browser::Options — Documentation by YARD 0.8.6.1

Class List Method List File List

# Module: Browser::Options

Included in:
  Browser
Defined in:
  lib/common/browser/options.rb

## Constant Summary

USER_AGENT_MODES =

      %w{ static semi-static random }

## Instance Attribute Summary (collapse)

- - (Object) available_user_agents

  Returns the value of attribute available_user_agents.

- - (Object) basic_auth

  Returns the value of attribute basic_auth.

- - (Object) cache_ttl

  Returns the value of attribute cache_ttl.

- - (Object) proxy

  Returns the value of attribute proxy.

- - (Object) proxy_auth

  Returns the value of attribute proxy_auth.

- - (String) user_agent

  The user agent, according to the user_agent_mode.

- - (Object) user_agent_mode

  Returns the value of attribute user_agent_mode.

## Instance Method Summary (collapse)

- - (Object) invalid_proxy_auth_format protected
- - (Integer) max_threads
- - (Object) max_threads=(threads)
- - (void) override_config(options = {}) protected

  Override with the options if they are set.

## Instance Attribute Details

### - (`Object`) available_user_agents

Returns the value of attribute available_user_agents

    8
    9
    10

    # File 'lib/common/browser/options.rb', line 8

    def available_user_agents
      @available_user_agents
    end

### - (`Object`) basic_auth

Returns the value of attribute basic_auth

    9
    10
    11

    # File 'lib/common/browser/options.rb', line 9

    def basic_auth
      @basic_auth
    end

### - (`Object`) cache_ttl

Returns the value of attribute cache_ttl

    8
    9
    10

    # File 'lib/common/browser/options.rb', line 8

    def cache_ttl
      @cache_ttl
    end

### - (`Object`) proxy

Returns the value of attribute proxy

    9
    10
    11

    # File 'lib/common/browser/options.rb', line 9

    def proxy
      @proxy
    end

### - (`Object`) proxy_auth

Returns the value of attribute proxy_auth

    9
    10
    11

    # File 'lib/common/browser/options.rb', line 9

    def proxy_auth
      @proxy_auth
    end

### - (`String`) user_agent

The user agent, according to the user_agent_mode

Returns:

- (`String`) —

  The user agent, according to the user_agent_mode

    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78

    # File 'lib/common/browser/options.rb', line 68

    def user_agent
      case @user_agent_mode
      when 'semi-static'
        unless @user_agent
          @user_agent = @available_user_agents.sample
        end
      when 'random'
        @user_agent = @available_user_agents.sample
      end
      @user_agent
    end

### - (`Object`) user_agent_mode

Returns the value of attribute user_agent_mode

    9
    10
    11

    # File 'lib/common/browser/options.rb', line 9

    def user_agent_mode
      @user_agent_mode
    end

## Instance Method Details

### - (`Object`) invalid_proxy_auth_format (protected)

    120
    121
    122

    # File 'lib/common/browser/options.rb', line 120

    def invalid_proxy_auth_format
      'Invalid proxy auth format, expected username:password or {proxy_username: username, proxy_password: password}'
    end

### - (`Integer`) max_threads

Returns:

- (`Integer`)

    31
    32
    33

    # File 'lib/common/browser/options.rb', line 31

    def max_threads
      @max_threads || 1
    end

### - (`Object`) max_threads=(threads)

    35
    36
    37
    38
    39
    40
    41
    42

    # File 'lib/common/browser/options.rb', line 35

    def max_threads=(threads)
      if threads.is_a?(Integer) && threads > 0
        @max_threads = threads
        @hydra = Typhoeus::Hydra.new(max_concurrency: threads)
      else
        raise 'max_threads must be an Integer > 0'
      end
    end

### - (`void`) override_config(options = {}) (protected)

This method returns an undefined value.

Override with the options if they are set

Parameters:

- options (`Hash`) (defaults to: `{}`)

    128
    129
    130
    131
    132
    133
    134

    # File 'lib/common/browser/options.rb', line 128

    def override_config(options = {})
      options.each do |option, value|
        if value != nil and OPTIONS.include?(option)
          self.send(:#{option}=", value)
        end
      end
    end