Class: DeviceAtlas::Device::DeviceApi
- Inherits:
-
Object
- Object
- DeviceAtlas::Device::DeviceApi
- Defined in:
- lib/deviceatlas/device/device_api.rb
Overview
The DeviceAtlas device detection API provides a way to detect devices based on the HTTP headers. Using these headers, the API returns device properties such as screen width, screen height, is mobile, vendor, model etc.
Direct Known Subclasses
Constant Summary collapse
- API_VERSION =
'2.1.0'
Instance Method Summary collapse
-
#data_creation_timestamp ⇒ String
Get the device data creation (JSON file) timestamp.
- #data_revision ⇒ String deprecated Deprecated.
-
#data_version ⇒ String
Get the device data (JSON file) version.
-
#get_properties(user_agent_or_headers, client_side = nil) ⇒ Hash<Symbol, Object>
Get the properties for a User-Agent or a set of HTTP headers merged with the client side properties (provided by the DeviceAtlas Client-side component).
-
#initialize(config = nil) ⇒ Object
constructor
Creates a new DeviceAtlas::Device::DeviceApi instance.
-
#load_data_from_file(path) ⇒ DeviceAtlas::Device::Tree
Load the DeviceAtlas device detection data into the API from a JSON file.
-
#load_data_from_string(json) ⇒ DeviceAtlas::Device::Tree
Load the DeviceAtlas device detection data into the API from a string.
-
#property_names ⇒ Hash<Symbol, String>
Get a set of all possible property names.
-
#set_config(config) ⇒ Object
Updates the DeviceApi instance with a new config.
Constructor Details
#initialize(config = nil) ⇒ Object
Creates a new DeviceAtlas::Device::DeviceApi instance.
Instance Method Details
#data_creation_timestamp ⇒ String
Get the device data creation (JSON file) timestamp.
#data_revision ⇒ String
Get the device data generator revision.
#data_version ⇒ String
Get the device data (JSON file) version.
#get_properties(user_agent_or_headers, client_side = nil) ⇒ Hash<Symbol, Object>
Get the properties for a User-Agent or a set of HTTP headers merged with the client side properties (provided by the DeviceAtlas Client-side component).
The DeviceAtlas Client-side component (JavaScript library) collects the client-side properties and puts them in a cookie. The contents of this cookie must be passed to this method. The client properties will override any properties discovered from the main JSON data file.
#load_data_from_file(path) ⇒ DeviceAtlas::Device::Tree
Load the DeviceAtlas device detection data into the API from a JSON file. The JSON data file is provided by the DeviceAtlas website.
#load_data_from_string(json) ⇒ DeviceAtlas::Device::Tree
Load the DeviceAtlas device detection data into the API from a string.
#property_names ⇒ Hash<Symbol, String>
Get a set of all possible property names. Note that the client side properties are not included in this set.
#set_config(config) ⇒ Object
Updates the DeviceApi instance with a new config.