Class: UserAgentParser::Parser
- Inherits:
-
Object
- Object
- UserAgentParser::Parser
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/user_agent_parser/parser.rb
Instance Attribute Summary collapse
-
#patterns_paths ⇒ Object
readonly
Returns the value of attribute patterns_paths.
Instance Method Summary collapse
-
#initialize(patterns_path: nil, patterns_paths: []) ⇒ Parser
constructor
A new instance of Parser.
- #parse(user_agent) ⇒ Object
- #patterns_path ⇒ Object
Constructor Details
#initialize(patterns_path: nil, patterns_paths: []) ⇒ Parser
Returns a new instance of Parser.
29 30 31 32 33 34 |
# File 'lib/user_agent_parser/parser.rb', line 29 def initialize(patterns_path: nil, patterns_paths: []) @patterns_paths = [patterns_path, *patterns_paths].compact @patterns_paths = [UserAgentParser::DefaultPatternsPath] if @patterns_paths.empty? @ua_patterns, @os_patterns, @device_patterns = load_patterns(@patterns_paths) end |
Instance Attribute Details
#patterns_paths ⇒ Object (readonly)
Returns the value of attribute patterns_paths.
27 28 29 |
# File 'lib/user_agent_parser/parser.rb', line 27 def patterns_paths @patterns_paths end |
Instance Method Details
#parse(user_agent) ⇒ Object
36 37 38 39 40 |
# File 'lib/user_agent_parser/parser.rb', line 36 def parse(user_agent) os = parse_os(user_agent) device = parse_device(user_agent) parse_ua(user_agent, os, device) end |
#patterns_path ⇒ Object
42 43 44 |
# File 'lib/user_agent_parser/parser.rb', line 42 def patterns_path patterns_paths.first end |