Class: Synthra::Types::AddressLocation::Country

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

Overview

Country type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



113
114
115
# File 'lib/synthra/types/address_location/locations.rb', line 113

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

#generate_invalid(rng, context, args) ⇒ Object



117
118
119
# File 'lib/synthra/types/address_location/locations.rb', line 117

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

#generate_random(rng, context, args) ⇒ String

Generate random country 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 country name



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/synthra/types/address_location/locations.rb', line 99

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

  else
    Faker::Address.country
  end

rescue StandardError
  rng.sample(["United States", "Canada", "Mexico", "Germany", "France"])
end