Class: DeviceAtlas::Device::ClientProps

Inherits:
PostWalkRules show all
Defined in:
lib/deviceatlas/device/client_props.rb

Overview

This class is used by the main API class and should not be used directly. This class tries to extract properties provided from the client side component.

Constant Summary collapse

CP_RULES =
:cpr
KEY_USER_AGENT =
:ua
KEY_USER_AGENT_PARSED =
:uap

Constants inherited from PostWalkRules

PostWalkRules::KEY_COMPARE_VALUES_CALLBACK, PostWalkRules::KEY_MATCHER_PROP_IDS_IN_USE, PostWalkRules::KEY_OPERATOR, PostWalkRules::KEY_OPERATOR_PARSED, PostWalkRules::KEY_PROPERTY_MATCHER, PostWalkRules::KEY_PROPERTY_MATCHER_PARSED, PostWalkRules::KEY_PROPERTY_VALUE, PostWalkRules::KEY_PROPERTY_VALUE_PARSED, PostWalkRules::KEY_RULE_ARR, PostWalkRules::KEY_RULE_ARR_PARSED, PostWalkRules::KEY_RULE_GROUPS, PostWalkRules::KEY_RULE_PROP_IDS_IN_USE, PostWalkRules::KEY_RULE_SET, PostWalkRules::KEY_RULE_SET_COUNT

Instance Attribute Summary

Attributes inherited from PostWalkRules

#branch, #tree_provider

Instance Method Summary collapse

Constructor Details

#initialize(tree) ⇒ ClientProps

Creates a new DeviceAtlas::Device::ClientProps instance.

Parameters:

  • tree (Tree)

    the reference to current tree instance

Instance Method Details

#parse_client_side_properties(client_side_original, tree_properties) ⇒ Hash

Parse the client side properties string into Hash<Symbol, Object>, sets to the tree_properties and returns the properties as Hash.

The client_side is of the form:

'bjs.webGl:1|bjs.geoLocation:1|sdeviceAspectRatio:16/10'

Each key:value part of client_side is checked for sanity, if it not valid then that key:val will be ignored.

The first character of the property name is the type of the value.

Parameters:

  • client_side_original (String)

    the client side properties string (from cookie)

  • tree_properties (Hash)

Returns:

  • (Hash)

#put_properties(client_side, tree_properties) ⇒ Object

Merge the tree walk properties with the client side properties and run any additional rules based on the client side and tree walk properties. The rules can define replacement or additional values for properties and can also provide a new User-Agent to be used for a second tree walk. This is typically a fake User-Agent mapped to a device that cannot normally be detected such as the various iPhone models.

Parameters:

  • client_side (String)

    the client side properties string (from cookie)

  • tree_properties (Hash)