Class: Synthra::Types::TechnologyInternet::UserAgent
- Defined in:
- lib/synthra/types/technology_internet/communication.rb
Overview
UserAgent type
Instance Method Summary collapse
- #generate_edge(rng, context, args) ⇒ Object
- #generate_invalid(rng, context, args) ⇒ Object
-
#generate_random(rng, context, args) ⇒ String
Generate random user agent.
Instance Method Details
#generate_edge(rng, context, args) ⇒ Object
152 153 154 |
# File 'lib/synthra/types/technology_internet/communication.rb', line 152 def generate_edge(rng, context, args) ["", "Mozilla/5.0", "Invalid User Agent"].sample(random: rng.instance_variable_get(:@random)) end |
#generate_invalid(rng, context, args) ⇒ Object
156 157 158 |
# File 'lib/synthra/types/technology_internet/communication.rb', line 156 def generate_invalid(rng, context, args) [nil, 123, [], {}].sample(random: rng.instance_variable_get(:@random)) end |
#generate_random(rng, context, args) ⇒ String
Generate random user agent
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/synthra/types/technology_internet/communication.rb', line 134 def generate_random(rng, context, args) adapter = faker_adapter(context) if adapter adapter.user_agent else Faker::Internet.user_agent end rescue StandardError rng.sample([ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36" ]) end |