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 brower is a specific version.
Instance Method Details
- (Query) accepts(langs = [])
Check if the browser accepts the specified languages.
615 616 617 618 |
# File 'lib/brauser/browser.rb', line 615 def accepts(langs = []) self.parse_accept_language(@accept_language) if !@languages ::Brauser::Query.new(self, (@languages & langs.ensure_array.uniq.compact.collect {|l| l.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.
569 570 571 572 573 574 575 576 577 578 579 580 581 |
# File 'lib/brauser/browser.rb', line 569 def is(names = [], versions = {}, platforms = []) self.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? || self.v?(versions)) && (platforms.blank? || self.on?(platforms)) ) end |
- (Query) on(platforms = [])
Check if the browser is on a specific platform.
606 607 608 609 |
# File 'lib/brauser/browser.rb', line 606 def on(platforms = []) self.parse_agent(@agent) if !@platform ::Brauser::Query.new(self, platforms.blank? || platforms.ensure_array.uniq.compact.collect {|p| p.ensure_string.to_sym }.include?(@platform)) end |
- (Query) v(versions = {})
Checks if the brower is a specific version.
587 588 589 590 591 592 593 594 595 596 597 598 599 600 |
# File 'lib/brauser/browser.rb', line 587 def v(versions = {}) self.parse_agent(@agent) if !@version rv = true versions = if versions.is_a?(String) then parse_versions_query(versions) elsif !versions.is_a?(::Hash) then {} else versions end ::Brauser::Query.new(self, versions.all? { |operator, value| Brauser::Browser.compare_versions(@version, operator, value) }) end |