Class: Synthra::Types::AddressLocation::City

Inherits:
Base
  • Object
show all
Defined in:
lib/synthra/types/address_location/locations.rb

Overview

City type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



29
30
31
# File 'lib/synthra/types/address_location/locations.rb', line 29

def generate_edge(rng, context, args)
  ["", "A", "Very Long City Name That Exceeds Normal Limits"].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



33
34
35
# File 'lib/synthra/types/address_location/locations.rb', line 33

def generate_invalid(rng, context, args)
  [nil, 123, [], {}].sample(random: rng.instance_variable_get(:@random))
end

#generate_random(rng, context, args) ⇒ String

Generate random city name

Parameters:

  • rng (Generator::RNG)

    random number generator (not directly used)

  • context (Generator::Context)

    generation context

  • args (Hash)

    type arguments (not used)

Returns:

  • (String)

    generated city name



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/synthra/types/address_location/locations.rb', line 15

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

  else
    Faker::Address.city
  end

rescue StandardError
  rng.sample(["New York", "Los Angeles", "Chicago", "Houston", "Phoenix"])
end