Class: DeviceAtlas::Device::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/deviceatlas/device/tree.rb

Overview

This class is used by the main API class and should not be used directly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, config) ⇒ Tree

Create a new instance of Tree.

Parameters:

Instance Attribute Details

#data_revisionString (readonly)

The device data (JSON file) version.

Returns:

#stock_ua_headersArray<String> (readonly)

A list of HTTP headers which may contain the original User-Agent.

Returns:

#treeHash (readonly)

Returns:

  • (Hash)

Instance Method Details

#data_creation_timestampString

Parse the device data creation (JSON file) timestamp.

Returns:

  • (String)

    the creation timestamp of the device data file

#data_versionString

Parse the device data (JSON file) version.

Returns:

  • (String)

    the version of the device data file

#property_name_by_id(property_id) ⇒ String

Get the name of a property from its identifier.

Parameters:

  • property_id (Symbol)

Returns:

  • (String)

    name of a property

#property_namesHash<PropertyName>

Get the names of all the possible properties stored in the tree.

Returns:

  • (Hash<PropertyName>)

    the property names.

#property_type_by_id(property_id) ⇒ Char

Get the type of a property from its identifier.

Parameters:

  • property_id (Symbol)

Returns:

  • (Char)

    type of a property

#property_value_by_id(value_id) ⇒ String

Get the value of a property from its identifier.

Returns:

  • (String)

    the version of the device data file

#property_value_typed(value_id, byte) ⇒ Object

Convert the value of a property based on its data type.

Parameters:

  • value_id (Integer)

    the identifier of a property value

  • byte (String)

    a character representing the data type of a property value

Returns:

  • (Object)

#put_properties(user_agent, stock_user_agents, client_side = nil, properties) ⇒ Object

Get properties from tree walk/ua/client-side.

Parameters:

  • user_agent (String)

    the User-Agent

  • stock_user_agents (Array<String>)

    the list of candidate User-Agent strings to be used for tree walk

  • client_side (String) (defaults to: nil)

    the content of the cookie containing the client-side properties

  • properties (Hash)

#put_tree_walk_properties(user_agent, stock_user_agents = nil, properties) ⇒ Object

Get properties from tree walk/ua.

Parameters:

  • user_agent (String)

    the User-Agent (from the original User-Agent header)

  • stock_user_agents (Hash) (defaults to: nil)

    the list of candidate User-Agent strings to be used for tree walk

  • properties (Hash)

#set_config(config) ⇒ Object