Module: Brauser::Browseable::Querying

Included in:
Brauser::Browser
Defined in:
lib/brauser/browseable/querying.rb

Overview

Methods to end querying.

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) accepts?(langs = [])

Check if the browser accepts the specified languages.

Parameters:

  • langs (String|Array) (defaults to: [])

    A list of languages to match against.

Returns:

  • (Boolean)

    true if current browser matches, false otherwise.



48
49
50
# File 'lib/brauser/browseable/querying.rb', line 48

def accepts?(langs = [])
  accepts(langs).result
end

- (Boolean) is?(names = [], versions = {}, platforms = [])

Checks if the browser is a specific name and optionally of a specific version and platform.

Parameters:

  • names (Symbol|Array) (defaults to: [])

    A list of specific names to match. Also, this meta-names are supported: :capable and :tablet.

  • versions (Hash) (defaults to: {})

    An hash with specific version to match against. Need to be in form {:operator => version}, where operator is one of :lt, :lte, :eq, :gt, :gte.

  • platforms (Symbol|Array) (defaults to: [])

    A list of specific platform to match. Valid values are all those possible for the platform attribute.

Returns:

  • (Boolean)

    true if current browser matches, false otherwise.

See Also:



22
23
24
# File 'lib/brauser/browseable/querying.rb', line 22

def is?(names = [], versions = {}, platforms = [])
  is(names, versions, platforms).result
end

- (Boolean) on?(platforms = [])

Check if the browser is on a specific platform.

Parameters:

  • platforms (Symbol|Array) (defaults to: [])

    A list of specific platform to match.

Returns:

  • (Boolean)

    true if current browser matches, false otherwise.



40
41
42
# File 'lib/brauser/browseable/querying.rb', line 40

def on?(platforms = [])
  on(platforms).result
end

- (Boolean) supported?(supported)

Check if the browser is supported.

Parameters:

  • supported (Hash|String)

    A map of engines and minimum supported major version, or a path to YAML file containing the map.

Returns:

  • (Boolean)

    true if current browser is supported, false otherwise.



56
57
58
59
60
# File 'lib/brauser/browseable/querying.rb', line 56

def supported?(supported)
  supported = YAML.load_file(supported).symbolize_keys if supported.is_a?(String)
  minimum = supported[name]
  (minimum && v?(gte: minimum)).to_boolean
end

- (Boolean) version?(versions = {}) Also known as: v?

Checks if the browser is a specific version.

Parameters:

  • versions (String|Hash) (defaults to: {})

    A string in the form operator version && ... (example: >= 7 && < 4) or an hash with specific version to match against, in form {:operator => version}, where operator is one of :lt, :lte, :eq, :gt, :gte.

Returns:

  • (Boolean)

    true if current browser matches, false otherwise.



31
32
33
# File 'lib/brauser/browseable/querying.rb', line 31

def version?(versions = {})
  version(versions).result
end