Module: Brauser::Browseable::General::ClassMethods
- Defined in:
- lib/brauser/browseable/general.rb
Overview
Class methods.
Instance Method Summary collapse
-
#browsers ⇒ Hash
Returns the list of browser that can be recognized.
-
#compare_versions(v1 = "", operator = :eq, v2 = "") ⇒ Boolean
Compares two versions.
-
#languages ⇒ Hash
Returns the list of languages that can be recognized.
-
#platforms ⇒ Hash
Returns the list of platforms that can be recognized.
Instance Method Details
#browsers ⇒ Hash
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.
21 22 23 |
# File 'lib/brauser/browseable/general.rb', line 21 def browsers @definitions[:browsers] end |
#compare_versions(v1 = "", operator = :eq, v2 = "") ⇒ Boolean
Compares two versions.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/brauser/browseable/general.rb', line 49 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? p1, p2 = find_relevant_tokens(v1, v2) p1, p2 = normalize_tokens(p1, p2) valid_results.include?(p1 <=> p2) else false end end |
#languages ⇒ Hash
Returns the list of languages that can be recognized.
The keys are the languages code, the values the labels.
39 40 41 |
# File 'lib/brauser/browseable/general.rb', line 39 def languages @definitions[:languages] end |
#platforms ⇒ Hash
Returns the list of platforms that can be recognized.
The keys are the platform name, values are arrays of the matcher and the label.
30 31 32 |
# File 'lib/brauser/browseable/general.rb', line 30 def platforms @definitions[:platforms] end |