Class: Brauser::Query
- Inherits:
-
Object
- Object
- Brauser::Query
- Defined in:
- lib/brauser/query.rb
Overview
A query to a browser. This class enables concatenation, like:
Brauser::Browser.new.is(:msie).v(">= 7").on?(:windows)
To end concatenation, use the ?
form of the queries or call .result
.
Instance Attribute Summary (collapse)
-
- (Object) result
The current result.
-
- (Object) target
The current browser.
Instance Method Summary (collapse)
-
- (Query) accepts(langs = [])
Check if the browser accepts the specified languages.
-
- (Boolean) accepts?(langs = [])
Check if the browser accepts the specified languages.
-
- (Query) initialize(target, result = true)
constructor
Creates a new query.
-
- (Query) is(names = [], versions = {}, platforms = [])
Checks if the browser is a specific name and optionally of a specific version and platform.
-
- (Boolean) 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.
-
- (Boolean) on?(platforms = [])
Check if the browser is on a specific platform.
-
- (Query) v(versions = {})
Checks if the brower is a specific version.
-
- (Boolean) v?(versions = {})
Checks if the brower is a specific version.
Constructor Details
- (Query) initialize(target, result = true)
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
- (Object) result
The current result.
21 22 23 |
# File 'lib/brauser/query.rb', line 21 def result @result end |
- (Object) target
The current browser.
18 19 20 |
# File 'lib/brauser/query.rb', line 18 def target @target end |
Instance Method Details
- (Query) accepts(langs = [])
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 |
- (Boolean) accepts?(langs = [])
114 115 116 |
# File 'lib/brauser/query.rb', line 114 def accepts?(langs = []) @result ? @target.accepts?(langs) : @result end |
- (Query) is(names = [], versions = {}, platforms = [])
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 |
- (Boolean) is?(names = [], versions = {}, platforms = [])
57 58 59 |
# File 'lib/brauser/query.rb', line 57 def is?(names = [], versions = {}, platforms = []) @result ? @target.is?(names, versions, platforms) : @result end |
- (Query) on(platforms = [])
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 |
- (Boolean) on?(platforms = [])
95 96 97 |
# File 'lib/brauser/query.rb', line 95 def on?(platforms = []) @result ? @target.on?(platforms) : @result end |
- (Query) v(versions = {})
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 |