Class: DeviceAtlas::Device::DeviceApiWeb

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

Overview

DeviceApiWeb is the class that lets us use user's headers transparently. We do not need to explicitly pass them as parameter to the properties() method.

Constant Summary

Constants inherited from DeviceApi

DeviceAtlas::Device::DeviceApi::API_VERSION

Instance Method Summary collapse

Methods inherited from DeviceApi

#data_creation_timestamp, #data_revision, #data_version, #load_data_from_file, #load_data_from_string, #property_names, #set_config

Constructor Details

#initialize(config = nil) ⇒ Object

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

Examples:

Create an object with default configuration

device_api_web = DeviceAtlas::Device::DeviceApiWeb.new

Create an object passing custom configuration

config = DeviceAtlas::Device::Config.new
config.include_ua_props = false
config.include_lang_props = false
device_api_web = DeviceAtlas::Device::DeviceApiWeb.new(config)

Parameters:

Instance Method Details

#get_properties(request) ⇒ Hash<Symbol, Object>

Get the Device properties for the given Net::HTTP request. The most suitable headers are extracted and used for detection and property lookup.

If the client-side component has been used and the client-side properties exists in the client-side cookie, then the client-side properties will be included in the result and the device detection for certain devices such as iPhone models will be done more accurately.

Depending on the configuration, the final properties set may include User-Agent dynamic properties and language/locale properties.

Parameters:

  • request (Net::HTTP)

    the request object to find the most suitable headers

Returns:

  • (Hash<Symbol, Object>)

    properties detected