Module: Brauser::Queries

Included in:
Query
Defined in:
lib/brauser/query.rb

Overview

Methods to make queries.

Instance Method Summary (collapse)

Instance Method Details

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

Check if the browser accepts the specified languages.

This version returns a boolean and it is equal to append a call to #result to the method `#accepts.

Parameters:

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

    A list of languages to match against.

Returns:

  • (Boolean)

    true if current browser matches, false otherwise.



96
97
98
# File 'lib/brauser/query.rb', line 96

def accepts?(langs = [])
  @result ? @target.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.

This version returns a boolean and it is equal to append a call to #result to the method #is.

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 any form that #v understands.

  • 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:



66
67
68
# File 'lib/brauser/query.rb', line 66

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

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

Check if the browser is on a specific platform.

This version returns a boolean and it is equal to append a call to #result to the method `#on.

Parameters:

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

    A list of specific platform to match.

Returns:

  • (Boolean)

    true if current browser matches, false otherwise.



86
87
88
# File 'lib/brauser/query.rb', line 86

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

- (Boolean) v?(versions = {})

Checks if the browser is a specific version.

This version returns a boolean and it is equal to append a call to #result to the method #v.

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.



76
77
78
# File 'lib/brauser/query.rb', line 76

def v?(versions = {})
  @result ? @target.v?(versions) : @result
end