module Browser::Bots

def self.detect_empty_ua!

def self.detect_empty_ua!
  @detect_empty_ua = true
end

def self.detect_empty_ua?

def self.detect_empty_ua?
  !!@detect_empty_ua
end

def bot?

def bot?
  bot_with_empty_ua? || BOTS.any? {|key, _| ua.include?(key) }
end

def bot_name

def bot_name
  return unless bot?
  return "Generic Bot" if bot_with_empty_ua?
  BOTS.find {|key, _| ua.include?(key) }.first
end

def bot_with_empty_ua?

def bot_with_empty_ua?
  Browser::Bots.detect_empty_ua? && ua.strip == ""
end

def search_engine?

def search_engine?
  SEARCH_ENGINES.any? {|key, _| ua.include?(key) }
end