class UserAgentRandomizer::UserAgent
Attributes
string[RW]
type[RW]
Public Class Methods
fetch(options = {})
click to toggle source
# File lib/user_agent_randomizer/user_agent.rb, line 12 def self.fetch(options = {}) type = options[:type] ua_types = UserAgentRandomizer.user_agent_types user_agents_hash = UserAgentRandomizer.user_agents_hash if ua_types.include?(type) UserAgentRandomizer::UserAgent.new(type: type, string: user_agents_hash[type].sample) else ua = UserAgentRandomizer.user_agents_array.sample UserAgentRandomizer::UserAgent.new(type: ua[:type], string: ua[:string]) end end
new(options = {})
click to toggle source
# File lib/user_agent_randomizer/user_agent.rb, line 7 def initialize(options = {}) @type = options[:type] @string = options[:string] end