Class: Zero::Request::Client
- Inherits:
-
Object
- Object
- Zero::Request::Client
- 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
-
#address ⇒ String
readonly
the ip address of the client.
-
#hostname ⇒ String
readonly
the hostname of the client.
-
#user_agent ⇒ String
readonly
the user agent of the client.
Instance Method Summary collapse
-
#initialize(environment) ⇒ Client
constructor
creates a new client with the data of the request environment.
Constructor Details
#initialize(environment) ⇒ Client
creates a new client with the data of the request environment
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
#address ⇒ String (readonly)
the ip address of the client
22 23 24 |
# File 'lib/zero/request/client.rb', line 22 def address @address end |
#hostname ⇒ String (readonly)
the hostname of the client
25 26 27 |
# File 'lib/zero/request/client.rb', line 25 def hostname @hostname end |
#user_agent ⇒ String (readonly)
the user agent of the client
28 29 30 |
# File 'lib/zero/request/client.rb', line 28 def user_agent @user_agent end |