Class: Brauser::Query
- Inherits:
-
Object
- Object
- Brauser::Query
- Defined in:
- lib/brauser/query.rb
Overview
Instance Attribute Summary collapse
-
#result ⇒ Object
The current result.
-
#target ⇒ Object
The current browser.
Instance Method Summary collapse
-
#accepts(langs = []) ⇒ Query
Check if the browser accepts the specified languages.
-
#accepts?(langs = []) ⇒ Boolean
Check if the browser accepts the specified languages.
-
#initialize(target, result = true) ⇒ Query
constructor
Creates a new query.
-
#is(names = [], versions = {}, platforms = []) ⇒ Query
Checks if the browser is a specific name and optionally of a specific version and platform.
-
#is?(names = [], versions = {}, platforms = []) ⇒ Boolean
Checks if the browser is a specific name and optionally of a specific version and platform.
-
#on(platforms = []) ⇒ Query
Check if the browser is on a specific platform.
-
#on?(platforms = []) ⇒ Boolean
Check if the browser is on a specific platform.
-
#v(versions = {}) ⇒ Query
Checks if the brower is a specific version.
-
#v?(versions = {}) ⇒ Boolean
Checks if the brower is a specific version.
Constructor Details
#initialize(target, result = true) ⇒ Query
Creates a new query.
27 28 29 30 |
# File 'lib/brauser/query.rb', line 27 def initialize(target, result = true) @target = target @result = result end |
Instance Attribute Details
#result ⇒ Object
The current result.
21 22 23 |
# File 'lib/brauser/query.rb', line 21 def result @result end |
#target ⇒ Object
The current browser.
18 19 20 |
# File 'lib/brauser/query.rb', line 18 def target @target end |
Instance Method Details
#accepts(langs = []) ⇒ Query
Check if the browser accepts the specified languages.
103 104 105 106 |
# File 'lib/brauser/query.rb', line 103 def accepts(langs = []) @result = self.accepts?(langs) self end |
#accepts?(langs = []) ⇒ Boolean
114 115 116 |
# File 'lib/brauser/query.rb', line 114 def accepts?(langs = []) @result ? @target.accepts?(langs) : @result end |
#is(names = [], versions = {}, platforms = []) ⇒ Query
Checks if the browser is a specific name and optionally of a specific version and platform.
41 42 43 44 |
# File 'lib/brauser/query.rb', line 41 def is(names = [], versions = {}, platforms = []) @result = self.is?(names, versions, platforms) self end |
#is?(names = [], versions = {}, platforms = []) ⇒ Boolean
57 58 59 |
# File 'lib/brauser/query.rb', line 57 def is?(names = [], versions = {}, platforms = []) @result ? @target.is?(names, versions, platforms) : @result end |
#on(platforms = []) ⇒ Query
Check if the browser is on a specific platform.
84 85 86 87 |
# File 'lib/brauser/query.rb', line 84 def on(platforms = []) @result = self.on?(platforms) self end |
#on?(platforms = []) ⇒ Boolean
95 96 97 |
# File 'lib/brauser/query.rb', line 95 def on?(platforms = []) @result ? @target.on?(platforms) : @result end |
#v(versions = {}) ⇒ Query
Checks if the brower is a specific version.
65 66 67 68 |
# File 'lib/brauser/query.rb', line 65 def v(versions = {}) @result = self.v?(versions) self end |