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.


27
28
29
30
# File 'lib/user_agent_parser/parser.rb', line 27

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


25
26
27
# File 'lib/user_agent_parser/parser.rb', line 25

def patterns_path
  @patterns_path
end

Instance Method Details

#parse(user_agent) ⇒ Object


32
33
34
35
36
# File 'lib/user_agent_parser/parser.rb', line 32

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