Class: DetectLanguage::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/detect_language/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



43
44
45
46
47
48
# File 'lib/detect_language/configuration.rb', line 43

def initialize
  @api_key            = nil
  @api_version        = "0.2"
  @host               = "ws.detectlanguage.com"
  @user_agent         = "Detect Language API ruby gem"
end

Instance Attribute Details

#api_keyObject

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.



5
6
7
# File 'lib/detect_language/configuration.rb', line 5

def api_key
  @api_key
end

#api_versionObject

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



8
9
10
# File 'lib/detect_language/configuration.rb', line 8

def api_version
  @api_version
end

#hostObject

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



14
15
16
# File 'lib/detect_language/configuration.rb', line 14

def host
  @host
end

#http_open_timeoutObject

The HTTP open timeout in seconds.



24
25
26
# File 'lib/detect_language/configuration.rb', line 24

def http_open_timeout
  @http_open_timeout
end

#http_read_timeoutObject

The HTTP read timeout in seconds.



27
28
29
# File 'lib/detect_language/configuration.rb', line 27

def http_read_timeout
  @http_read_timeout
end

#portObject

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



18
19
20
# File 'lib/detect_language/configuration.rb', line 18

def port
  @port
end

#proxy_hostObject

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



30
31
32
# File 'lib/detect_language/configuration.rb', line 30

def proxy_host
  @proxy_host
end

#proxy_passObject

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



39
40
41
# File 'lib/detect_language/configuration.rb', line 39

def proxy_pass
  @proxy_pass
end

#proxy_portObject

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



33
34
35
# File 'lib/detect_language/configuration.rb', line 33

def proxy_port
  @proxy_port
end

#proxy_userObject

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



36
37
38
# File 'lib/detect_language/configuration.rb', line 36

def proxy_user
  @proxy_user
end

#secureObject Also known as: secure?

true for https connections, false for http connections.



21
22
23
# File 'lib/detect_language/configuration.rb', line 21

def secure
  @secure
end

#user_agentObject

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



11
12
13
# File 'lib/detect_language/configuration.rb', line 11

def user_agent
  @user_agent
end

Instance Method Details

#[](option) ⇒ Object

Allows config options to be read like a hash

Parameters:

  • option (Symbol)

    Key for a given attribute



65
66
67
# File 'lib/detect_language/configuration.rb', line 65

def [](option)
  send(option)
end

#protocolObject



50
51
52
53
54
55
56
# File 'lib/detect_language/configuration.rb', line 50

def protocol
  if secure?
    'https'
  else
    'http'
  end
end