Module: Brauser::Queryable::Chainers

Included in:
Brauser::Query
Defined in:
lib/brauser/queryable/chainers.rb

Overview

Methods to chain queries.

Instance Method Summary (collapse)

Instance Method Details

- (Query) accepts(langs = [])

Check if the browser accepts the specified languages.

Parameters:

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

    A list of languages to match against.

Returns:

  • (Query)

    The query itself.



50
51
52
53
# File 'lib/brauser/queryable/chainers.rb', line 50

def accepts(langs = [])
  @result = accepts?(langs)
  self
end

- (Query) 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 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:

  • (Query)

    The query itself.

See Also:

  • #version?
  • #on?


21
22
23
24
# File 'lib/brauser/queryable/chainers.rb', line 21

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

- (Query) 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:

  • (Query)

    The query itself.



41
42
43
44
# File 'lib/brauser/queryable/chainers.rb', line 41

def on(platforms = [])
  @result = on?(platforms)
  self
end

- (Query) 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:

  • (Query)

    The query itself.



31
32
33
34
# File 'lib/brauser/queryable/chainers.rb', line 31

def version(versions = {})
  @result = version?(versions)
  self
end