Class: UserAgentParser::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/user_agent_parser/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Parser

Returns a new instance of Parser.



8
9
10
11
# File 'lib/user_agent_parser/parser.rb', line 8

def initialize(options={})
  @patterns_path = options[:patterns_path] || UserAgentParser::DefaultPatternsPath
  @ua_patterns, @os_patterns, @device_patterns = load_patterns(patterns_path)
end

Instance Attribute Details

#patterns_pathObject (readonly)

Returns the value of attribute patterns_path.



6
7
8
# File 'lib/user_agent_parser/parser.rb', line 6

def patterns_path
  @patterns_path
end

Instance Method Details

#parse(user_agent) ⇒ Object



13
14
15
16
17
# File 'lib/user_agent_parser/parser.rb', line 13

def parse(user_agent)
  os = parse_os(user_agent)
  device = parse_device(user_agent)
  parse_ua(user_agent, os, device)
end