Class: DoubleAgent::OSParser

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_symObject (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

#osObject (readonly)

The operating system name



46
47
48
# File 'lib/double_agent/parser.rb', line 46

def os
  @os
end

#symObject (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

#familyObject

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

Returns:

  • (Boolean)


61
62
63
# File 'lib/double_agent/parser.rb', line 61

def mobile?
  @mobile
end