Module: Brauser::BrowserMethods::PartialQuerying
- Included in:
- Brauser::Browser
- Defined in:
- lib/brauser/browser.rb
Overview
Methods to query with chaining.
Instance Method Summary (collapse)
-
- (Query) accepts(langs = [])
Check if the browser accepts the specified languages.
-
- (Query) is(names = [], versions = {}, platforms = [])
Checks if the browser is a specific name and optionally of a specific version and platform.
-
- (Query) on(platforms = [])
Check if the browser is on a specific platform.
-
- (Query) v(versions = {})
Checks if the browser is a specific version.
Instance Method Details
- (Query) accepts(langs = [])
Check if the browser accepts the specified languages.
548 549 550 551 552 |
# File 'lib/brauser/browser.rb', line 548 def accepts(langs = []) parse_accept_language(@accept_language) if !@languages ::Brauser::Query.new(self, (@languages & langs.ensure_array(nil, true, true, :to_s)).present?) end |
- (Query) is(names = [], versions = {}, platforms = [])
Checks if the browser is a specific name and optionally of a specific version and platform.
509 510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'lib/brauser/browser.rb', line 509 def is(names = [], versions = {}, platforms = []) parse_agent(@agent) if !@name names = adjust_names(names) versions = parse_versions_query(versions) platforms = platforms.ensure_array ::Brauser::Query.new(self, (names.blank? || (names.include?(@name) && check_capable(names))) && (versions.blank? || v?(versions)) && (platforms.blank? || on?(platforms)) ) end |
- (Query) on(platforms = [])
Check if the browser is on a specific platform.
538 539 540 541 542 |
# File 'lib/brauser/browser.rb', line 538 def on(platforms = []) parse_agent(@agent) if !@platform ::Brauser::Query.new(self, platforms.blank? || platforms.ensure_array(nil, true, true, :to_sym).include?(@platform)) end |
- (Query) v(versions = {})
Checks if the browser is a specific version.
527 528 529 530 531 532 |
# File 'lib/brauser/browser.rb', line 527 def v(versions = {}) parse_agent(@agent) if !@version versions = versions.is_a?(String) ? parse_versions_query(versions) : versions.ensure_hash ::Brauser::Query.new(self, versions.all? { |operator, value| Brauser::Browser.compare_versions(@version, operator, value) }) end |