Class: Tweakphoeus::UserAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/tweakphoeus/user_agent.rb

Overview

User agent data generator

Constant Summary collapse

OS_DATA =
{
  types: %i[win linux mac],
  linux_distro: ['Ubuntu', 'Debian', 'Fedora', 'gNewSense', 'Linux Mint', 'OpenSUSE', 'Mandriva'],
  arch: %w[x86 x86_64],
  win_arch: ['Win64; x64', 'WOW64']
}.freeze

Class Method Summary collapse

Class Method Details

.random(systems: ) ⇒ Object



14
15
16
17
18
# File 'lib/tweakphoeus/user_agent.rb', line 14

def random(systems: OS_DATA[:types])
  user_agent = "Mozilla/5.0 (#{os[systems.sample]}) #{browser}"
  firefox_version = user_agent.match(%r{Firefox/([0-9.]+)})
  user_agent.gsub(')', "; rv:#{firefox_version[1]})") if firefox_version.is_a?(MatchData)
end