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.
499 500 501 |
# File 'lib/brauser/browser.rb', line 499 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.
485 486 487 488 489 490 491 492 493 |
# File 'lib/brauser/browser.rb', line 485 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 |