Module: Brauser::BrowserMethods::Parsing
- Included in:
- Brauser::Browser
- Defined in:
- lib/brauser/browser.rb
Overview
Methods to parse the user agent.
Instance Method Summary (collapse)
-
- (Array) parse_accept_language(accept_language = nil)
Parses the Accept-Language header.
-
- (Boolean) parse_agent(agent = nil)
Parses the User-Agent header.
Instance Method Details
- (Array) parse_accept_language(accept_language = nil)
Parses the Accept-Language header.
444 445 446 |
# File 'lib/brauser/browser.rb', line 444 def parse_accept_language(accept_language = nil) accept_language.ensure_string.gsub(/;q=[\d.]+/, "").split(",").collect {|l| l.downcase.strip }.select{|l| l.present? } end |
- (Boolean) parse_agent(agent = nil)
Parses the User-Agent header.
430 431 432 433 434 435 436 437 438 |
# File 'lib/brauser/browser.rb', line 430 def parse_agent(agent = nil) agent = agent.ensure_string @name, _ = match_name_and_version(agent) @version = adjust_version(@version) @platform = match_platform(agent) (@name != :unknown) ? true : false end |