class DetectLanguage::Configuration

Attributes

api_key[RW]

The API key for your project, found on your homepage after you login into detectlanguage.com website Defaults to 'demo', which has a limited number of requests.

api_version[RW]

The API version you are using (defaults to 0.2).

host[RW]

The host to connect to (defaults to ws.detectlanguage.com).

http_open_timeout[RW]

The HTTP open timeout in seconds.

http_read_timeout[RW]

The HTTP read timeout in seconds.

port[RW]

The port on which your DetectLanguage server runs (defaults to 443 for secure connections, 80 for insecure connections).

proxy_host[RW]

The hostname of your proxy server (if using a proxy).

proxy_pass[RW]

The password to use when logging into your proxy server (if using a proxy).

proxy_port[RW]

The port of your proxy server (if using a proxy).

proxy_user[RW]

The username to use when logging into your proxy server (if using a proxy).

secure[RW]

true for https connections, false for http connections.

secure?[RW]

true for https connections, false for http connections.

user_agent[RW]

HTTP request user agent (defaults to 'Detect Language API ruby gem').

Public Class Methods

new() click to toggle source
# File lib/detect_language/configuration.rb, line 43
def initialize
  @api_key            = nil
  @api_version        = "0.2"
  @host               = "ws.detectlanguage.com"
  @user_agent         = "detectlanguage-ruby/#{VERSION}"
end

Public Instance Methods

[](option) click to toggle source

Allows config options to be read like a hash

@param [Symbol] option Key for a given attribute

# File lib/detect_language/configuration.rb, line 65
def [](option)
  send(option)
end
protocol() click to toggle source
# File lib/detect_language/configuration.rb, line 50
def protocol
  if secure?
    'https'
  else
    'http'
  end
end

Private Instance Methods

default_port() click to toggle source

Determines what port should we use for sending requests. @return [Fixnum] Returns 443 if you've set secure to true in your configuration, and 80 otherwise.

# File lib/detect_language/configuration.rb, line 74
def default_port
  if secure?
    443
  else
    80
  end
end