Class: WurflCloud::Environment
- Inherits:
-
Object
- Object
- WurflCloud::Environment
- Defined in:
- lib/wurfl_cloud/environment.rb
Constant Summary collapse
- USER_AGENT_FIELDS =
[ 'HTTP_X_DEVICE_USER_AGENT', 'HTTP_X_ORIGINAL_USER_AGENT', 'HTTP_X_OPERAMINI_PHONE_UA', 'HTTP_X_SKYFIRE_PHONE', 'HTTP_X_BOLT_PHONE_UA', 'HTTP_USER_AGENT' ]
Instance Attribute Summary collapse
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
-
#x_accept ⇒ Object
readonly
Returns the value of attribute x_accept.
-
#x_forwarded_for ⇒ Object
readonly
Returns the value of attribute x_forwarded_for.
-
#x_wap_profile ⇒ Object
readonly
Returns the value of attribute x_wap_profile.
Instance Method Summary collapse
-
#initialize(http_env = {}) ⇒ Environment
constructor
Extracts the http headers that are relevant to the library.
Constructor Details
#initialize(http_env = {}) ⇒ Environment
Extracts the http headers that are relevant to the library. They are used by the client when communicating with the API server.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wurfl_cloud/environment.rb', line 24 def initialize(http_env={}) USER_AGENT_FIELDS.each do |ua_field| @user_agent ||= http_env[ua_field] end @x_accept = http_env["HTTP_ACCEPT"] if !(@x_wap_profile = http_env["HTTP_X_WAP_PROFILE"]) @x_wap_profile = http_env["HTTP_PROFILE"] end if http_env["REMOTE_ADDR"] @x_forwarded_for = http_env["REMOTE_ADDR"] @x_forwarded_for = "#{x_forwarded_for}, #{http_env["HTTP_X_FORWARDED_FOR"]}" if http_env["HTTP_X_FORWARDED_FOR"] end end |
Instance Attribute Details
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
19 20 21 |
# File 'lib/wurfl_cloud/environment.rb', line 19 def user_agent @user_agent end |
#x_accept ⇒ Object (readonly)
Returns the value of attribute x_accept.
19 20 21 |
# File 'lib/wurfl_cloud/environment.rb', line 19 def x_accept @x_accept end |
#x_forwarded_for ⇒ Object (readonly)
Returns the value of attribute x_forwarded_for.
19 20 21 |
# File 'lib/wurfl_cloud/environment.rb', line 19 def x_forwarded_for @x_forwarded_for end |
#x_wap_profile ⇒ Object (readonly)
Returns the value of attribute x_wap_profile.
19 20 21 |
# File 'lib/wurfl_cloud/environment.rb', line 19 def x_wap_profile @x_wap_profile end |