device v0.3.8 Device

Summary

Functions

Return a boolean indicating whether the given User-Agent string evaluates as a bot device

Return a boolean indicating whether the given User-Agent string evaluates as a car device

Return a boolean indicating whether the given User-Agent string evaluates as a desktop device

Return a boolean indicating whether the given User-Agent string evaluates as a phone device

Return a boolean indicating whether the given User-Agent string evaluates as a tablet device

Functions

is_bot?(ua)

Specs

is_bot?(String.t | nil) :: boolean

Return a boolean indicating whether the given User-Agent string evaluates as a bot device

Examples

iex> Device.is_bot?(“LinkedInBot/1.0 (compatible; Mozilla/5.0; Jakarta Commons-HttpClient/3.1 +http://www.linkedin.com)”) true iex> Device.is_bot?(“Mozilla/5.0 (X11; u; Linux; C) AppleWebKit /533.3 (Khtml, like Gheko) QtCarBrowser Safari /533.3”) false

is_car?(ua)

Specs

is_car?(String.t | nil) :: boolean

Return a boolean indicating whether the given User-Agent string evaluates as a car device

Examples

iex> Device.is_car?(“Mozilla/5.0 (X11; u; Linux; C) AppleWebKit /533.3 (Khtml, like Gheko) QtCarBrowser Safari /533.3”) true iex> Device.is_car?(“Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B367”) false

is_desktop?(ua)

Specs

is_desktop?(String.t | nil) :: boolean

Return a boolean indicating whether the given User-Agent string evaluates as a desktop device

Examples

iex> Device.is_desktop?(“Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0”) true iex> Device.is_desktop?(“Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B367”) false

is_phone?(ua)

Specs

is_phone?(String.t | nil) :: boolean

Return a boolean indicating whether the given User-Agent string evaluates as a phone device

Examples

iex> Device.is_phone?(“Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 7.11) ASUS-P552w/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1”) true iex> Device.is_phone?(“Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B367”) false

is_tablet?(ua)

Specs

is_tablet?(String.t | nil) :: boolean

Return a boolean indicating whether the given User-Agent string evaluates as a tablet device

Examples

iex> Device.is_tablet?(“Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B367”) true iex> Device.is_tablet?(“”) false