Module: Brauser::BrowserMethods::PartialQuerying
- Included in:
- Brauser::Browser
- Defined in:
- lib/brauser/browser.rb
Overview
Methods to query with chaining.
Instance Method Summary collapse
-
#accepts(langs = []) ⇒ Query
Check if the browser accepts the specified languages.
-
#is(names = [], versions = {}, platforms = []) ⇒ Query
Checks if the browser is a specific name and optionally of a specific version and platform.
-
#on(platforms = []) ⇒ Query
Check if the browser is on a specific platform.
-
#v(versions = {}) ⇒ Query
Checks if the browser is a specific version.
Instance Method Details
#accepts(langs = []) ⇒ Query
Check if the browser accepts the specified languages.
567 568 569 570 571 |
# File 'lib/brauser/browser.rb', line 567 def accepts(langs = []) parse_accept_language(@accept_language) if !@languages ::Brauser::Query.new(self, (@languages & langs.ensure_array(nil, true, true, true, :to_s)).present?) end |
#is(names = [], versions = {}, platforms = []) ⇒ Query
Checks if the browser is a specific name and optionally of a specific version and platform.
527 528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/brauser/browser.rb', line 527 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 |
#on(platforms = []) ⇒ Query
Check if the browser is on a specific platform.
557 558 559 560 561 |
# File 'lib/brauser/browser.rb', line 557 def on(platforms = []) parse_agent(@agent) if !@platform ::Brauser::Query.new(self, platforms.blank? || platforms.ensure_array(nil, true, true, true, :to_sym).include?(@platform)) end |
#v(versions = {}) ⇒ Query
Checks if the browser is a specific version.
546 547 548 549 550 551 |
# File 'lib/brauser/browser.rb', line 546 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 |