Class: DoubleAgent::OSParser
- Inherits:
-
Object
- Object
- DoubleAgent::OSParser
- Defined in:
- lib/double_agent/parser.rb
Overview
Each OS in OS_DATA gets its own BrowserParser object. These parser objects are then used to parse specific data out of a user agent string.
Instance Attribute Summary collapse
-
#family_sym ⇒ Object
readonly
The operating system family name as a symbol.
-
#os ⇒ Object
readonly
The operating system name.
-
#sym ⇒ Object
readonly
The operating system name as a symbol.
Instance Method Summary collapse
-
#family ⇒ Object
Returns the OSParser for this OSParser object’s Family.
-
#initialize(sym, attrs = {}) ⇒ OSParser
constructor
Instantiate a new OSParser using an “OS family” element from OS_DATA.
-
#mobile? ⇒ Boolean
Returs true if this is mobile OS, false if not.
Constructor Details
#initialize(sym, attrs = {}) ⇒ OSParser
Instantiate a new OSParser using an “OS family” element from OS_DATA
53 54 55 56 57 58 |
# File 'lib/double_agent/parser.rb', line 53 def initialize(sym, attrs={}) @sym = sym @family_sym = attrs[:family_sym] || @sym @os = attrs[:name] @mobile = attrs[:mobile] || false end |
Instance Attribute Details
#family_sym ⇒ Object (readonly)
The operating system family name as a symbol
50 51 52 |
# File 'lib/double_agent/parser.rb', line 50 def family_sym @family_sym end |
#os ⇒ Object (readonly)
The operating system name
46 47 48 |
# File 'lib/double_agent/parser.rb', line 46 def os @os end |
#sym ⇒ Object (readonly)
The operating system name as a symbol
48 49 50 |
# File 'lib/double_agent/parser.rb', line 48 def sym @sym end |
Instance Method Details
#family ⇒ Object
Returns the OSParser for this OSParser object’s Family. E.g. the Ubuntu OSParser would return the GNU/Linux OSerParser. For OSes that are their own family (e.g. OS X) it will end up returning itself.
68 69 70 |
# File 'lib/double_agent/parser.rb', line 68 def family OS_PARSERS[family_sym] end |
#mobile? ⇒ Boolean
Returs true if this is mobile OS, false if not
61 62 63 |
# File 'lib/double_agent/parser.rb', line 61 def mobile? @mobile end |