Module: Brauser::Browseable::PartialQuerying
- Included in:
- Brauser::Browser
- Defined in:
- lib/brauser/browseable/partial_querying.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) version_equals_to(versions = {})
(also: #v)
Checks if the browser is a specific version.
Instance Method Details
- (Query) accepts(langs = [])
Check if the browser accepts the specified languages.
63 64 65 66 67 |
# File 'lib/brauser/browseable/partial_querying.rb', line 63 def accepts(langs = []) parse_accept_language(@accept_language) unless @languages ::Brauser::Query.new(self, (@languages & langs.ensure_array(nil, true, 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.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/brauser/browseable/partial_querying.rb', line 22 def is(names = [], versions = {}, platforms = []) parse_agent(@agent) unless @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? || version?(versions)) && (platforms.blank? || on?(platforms)) ) end |
- (Query) on(platforms = [])
Check if the browser is on a specific platform.
53 54 55 56 57 |
# File 'lib/brauser/browseable/partial_querying.rb', line 53 def on(platforms = []) parse_agent(@agent) unless @platform ::Brauser::Query.new(self, platforms.blank? || platforms.ensure_array(nil, true, true, true, :to_sym).include?(@platform)) end |
- (Query) version_equals_to(versions = {}) Also known as: v
Checks if the browser is a specific version.
41 42 43 44 45 46 |
# File 'lib/brauser/browseable/partial_querying.rb', line 41 def version_equals_to(versions = {}) parse_agent(@agent) unless @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 |