Class: BrowserslistUseragent::QueryNormalizer
- Inherits:
-
Object
- Object
- BrowserslistUseragent::QueryNormalizer
- Defined in:
- lib/browserslist_useragent/query_normalizer.rb
Overview
Normalizes browserslist query to existing browser family names
Constant Summary collapse
- NORMALIZED_NAMES =
{ bb: 'BlackBerry', and_chr: 'Chrome', ChromeAndroid: 'Chrome', FirefoxAndroid: 'Firefox', ff: 'Firefox', ie: 'Explorer', ie_mob: 'ExplorerMobile', and_ff: 'Firefox', ios_saf: 'iOS', op_mini: 'OperaMini', op_mob: 'OperaMobile', and_qq: 'QQAndroid', and_uc: 'UCAndroid' }.freeze
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(query) ⇒ QueryNormalizer
constructor
A new instance of QueryNormalizer.
Constructor Details
#initialize(query) ⇒ QueryNormalizer
Returns a new instance of QueryNormalizer.
24 25 26 |
# File 'lib/browserslist_useragent/query_normalizer.rb', line 24 def initialize(query) @query = query end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
22 23 24 |
# File 'lib/browserslist_useragent/query_normalizer.rb', line 22 def query @query end |
Instance Method Details
#call ⇒ Object
28 29 30 31 32 33 |
# File 'lib/browserslist_useragent/query_normalizer.rb', line 28 def call browser_name, browser_version = query.split(' ', 2) normalized_name = NORMALIZED_NAMES[browser_name.to_sym] || browser_name { family: normalized_name, version: browser_version } end |