Class: Zero::Request::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/zero/request/client.rb

Overview

This class represents all information about the client of a request.

Constant Summary collapse

KEY_REMOTE_ADDR =

the key for the ip of the client

'REMOTE_ADDR'
KEY_REMOTE_HOST =

the key for the hostname

'REMOTE_HOST'
KEY_USER_AGENT =

the key for the user agent

'HTTP_USER_AGENT'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Client

creates a new client with the data of the request environment

Parameters:

  • environment

    a hash representation of the request



14
15
16
17
18
# File 'lib/zero/request/client.rb', line 14

def initialize(environment)
  @address    = environment[KEY_REMOTE_ADDR]
  @hostname   = environment[KEY_REMOTE_HOST]
  @user_agent = environment[KEY_USER_AGENT]
end

Instance Attribute Details

#addressString (readonly)

the ip address of the client

Returns:

  • (String)

    the address of the client



22
23
24
# File 'lib/zero/request/client.rb', line 22

def address
  @address
end

#hostnameString (readonly)

the hostname of the client

Returns:

  • (String)

    the hostname of the client



25
26
27
# File 'lib/zero/request/client.rb', line 25

def hostname
  @hostname
end

#user_agentString (readonly)

the user agent of the client

Returns:

  • (String)

    the user agent of the client



28
29
30
# File 'lib/zero/request/client.rb', line 28

def user_agent
  @user_agent
end