Module: UAParser

Defined in:
lib/ua_parser.rb

Defined Under Namespace

Classes: Parser

Class Method Summary collapse

Class Method Details

.initializeObject



23
24
25
26
27
28
# File 'lib/ua_parser.rb', line 23

def self.initialize
  if !@initialize_bg_thread.nil? && @initialize_bg_thread.alive?
    @initialize_bg_thread.kill.join
  end
  @parser = Parser.new
end

.initialize_asyncObject



30
31
32
33
34
35
36
# File 'lib/ua_parser.rb', line 30

def self.initialize_async
  if !@initialize_bg_thread.nil? && @initialize_bg_thread.alive?
    @initialize_bg_thread.kill.join
  end
  @initialize_bg_thread = Thread.new { @parser = Parser.new }
  @initialize_bg_thread
end

.parse_device(*args) ⇒ Object



52
53
54
55
56
57
# File 'lib/ua_parser.rb', line 52

def self.parse_device(*args)
  if @parser.nil?
    initialize
  end
  @parser.parse_device(*args)
end

.parse_os(*args) ⇒ Object



38
39
40
41
42
43
# File 'lib/ua_parser.rb', line 38

def self.parse_os(*args)
  if @parser.nil?
    initialize
  end
  @parser.parse_os(*args)
end

.parse_ua(*args) ⇒ Object



45
46
47
48
49
50
# File 'lib/ua_parser.rb', line 45

def self.parse_ua(*args)
  if @parser.nil?
    initialize
  end
  @parser.parse_ua(*args)
end