Wootheex.UserAgent (wootheex v0.1.0) View Source

Link to this section Summary

Functions

Safely parses user agent to a struct

Parse user agent to a struct or raises an error

Link to this section Types

Specs

t() :: %Wootheex.UserAgent{
  browser_name: Wootheex.browser_name(),
  browser_type: Wootheex.browser_type(),
  browser_version: Wootheex.browser_version(),
  category: Wootheex.category(),
  os: Wootheex.os(),
  os_version: Wootheex.os_version(),
  vendor: Wootheex.vendor()
}

Link to this section Functions

Specs

parse(Wootheex.user_agent()) :: {:ok, t()} | {:error, any()}

Safely parses user agent to a struct

iex> Wootheex.UserAgent.parse "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36"
{:ok,
  %Wootheex.UserAgent{
    browser_name: "Chrome",
    browser_type: :browser,
    browser_version: "44.0.2403.155",
    category: :pc,
    os: "Mac OSX",
    os_version: "10.10.4",
    vendor: "Google"
  }
}

Specs

parse!(Wootheex.user_agent()) :: t()

Parse user agent to a struct or raises an error

iex> Wootheex.UserAgent.parse! "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36"
%Wootheex.UserAgent{
  browser_name: "Chrome",
  browser_type: :browser,
  browser_version: "44.0.2403.155",
  category: :pc,
  os: "Mac OSX",
  os_version: "10.10.4",
  vendor: "Google"
}