Class: DeviceAtlas::Device::UaProps

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

Overview

This class is used by the main API class and should not be used directly. This class tries to extract properties from the User-Agent string itself. This is a completely separate step to the main JSON tree walk but uses the results of the tree walk to optimise the property extraction. The property extraction is done in two steps.

Step 1: Try and identify the type of User-Agent and thus the set of property
extraction rules to run. This is optimised by the properties from the tree walk.

Step 2: Run the rules found in step 1 to try and extract the properties.

Constant Summary collapse

UA_RULES =
:uar
KEY_SKIP_IDS =
:sk
KEY_DEFAULT_REGEX_SET =
:d
KEY_RULE_GROUPS =
:rg
KEY_RULE_REGEX_ID =
:r
KEY_REGEXES =
:reg
KEY_REGEX_MATCH_POS =
:m
KEY_REFINE_REGEX_ID =
:f
KEY_SEARCH_REGEX_ID =
:s

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_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) ⇒ UaProps

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

Parameters:

Instance Method Details

#pre_process_rulesObject

#put_properties(user_agent, props_to_vals, tree_properties) ⇒ Object

Merge the tree walk properties with the User-Agent string properties using the User-Agent rules.

Parameters:

  • user_agent (String)

    the User-Agent to find properties for

  • props_to_vals (Hash)

    the result of the tree walk

  • tree_properties (Hash)