Class: Synthra::Types::TechnologyInternet::Url

Inherits:
Base
  • Object
show all
Defined in:
lib/synthra/types/technology_internet/communication.rb

Overview

Url type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



84
85
86
# File 'lib/synthra/types/technology_internet/communication.rb', line 84

def generate_edge(rng, context, args)
  ["", "http://", "http://a", "https://example.com"].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



88
89
90
# File 'lib/synthra/types/technology_internet/communication.rb', line 88

def generate_invalid(rng, context, args)
  [nil, 123, [], {}, "not-a-url", "missing-protocol.com"].sample(random: rng.instance_variable_get(:@random))
end

#generate_random(rng, context, args) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/synthra/types/technology_internet/communication.rb', line 70

def generate_random(rng, context, args)
  adapter = faker_adapter(context)
  if adapter
    adapter.url

  else
    Faker::Internet.url
  end

rescue StandardError
  "https://#{rng.sample(['example.com', 'test.com', 'demo.com'])}/#{rng.sample(['page', 'path', 'resource'])}"
end