Class: UserAgentParser::Parser::Patterns

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

Instance Method Summary collapse

Constructor Details

#initializePatterns

Returns a new instance of Patterns.



10
11
12
13
# File 'lib/hacks/user_agent_parser.rb', line 10

def initialize
  @cache = {}
  get # warm the cache for the default patterns
end

Instance Method Details

#get(path = nil) ⇒ Object



15
16
17
18
# File 'lib/hacks/user_agent_parser.rb', line 15

def get(path = nil)
  path = UserAgentParser::DefaultPatternsPath if path.nil?
  @cache[path] ||= load_and_parse(path)
end