Module: Brauser::BrowserMethods::General::ClassMethods
- Defined in:
- lib/brauser/browser.rb
Overview
Class methods.
Instance Method Summary (collapse)
-
- (Hash) browsers
Returns the list of browser that can be recognized.
-
- (Boolean) compare_versions(v1 = "", operator = :eq, v2 = "")
Compares two versions.
-
- (Hash) languages
Returns the list of languages that can be recognized.
-
- (Hash) platforms
Returns the list of platforms that can be recognized.
Instance Method Details
- (Hash) browsers
Returns the list of browser that can be recognized.
The keys are the browser name, the values are arrays of the name matcher, the version match and the label.
320 321 322 |
# File 'lib/brauser/browser.rb', line 320 def browsers registered_to_hash(@browsers) end |
- (Boolean) compare_versions(v1 = "", operator = :eq, v2 = "")
Compares two versions.
348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/brauser/browser.rb', line 348 def compare_versions(v1 = "", operator = :eq, v2 = "") valid_results = {lt: [-1], lte: [-1, 0], eq: [0], gte: [0, 1], gt: [1]}.fetch(operator, []) if valid_results.present? && v1.ensure_string.present? then p1, p2 = find_relevant_tokens(v1.ensure_string.strip, v2.ensure_string.strip) p1, p2 = normalize_tokens(p1, p2) valid_results.include?(p1 <=> p2) else false end end |
- (Hash) languages
Returns the list of languages that can be recognized.
The keys are the languages code, the values the labels.
338 339 340 |
# File 'lib/brauser/browser.rb', line 338 def languages @languages end |
- (Hash) platforms
Returns the list of platforms that can be recognized.
The keys are the platform name, values are arrays of the matcher and the label.
329 330 331 |
# File 'lib/brauser/browser.rb', line 329 def platforms registered_to_hash(@platforms) end |