Class: Synthra::Types::AddressLocation::AirportName

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

Overview

AirportName type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



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

def generate_edge(rng, context, args)
  ["", "A", "Very Long Airport Name"].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



37
38
39
# File 'lib/synthra/types/address_location/airports.rb', line 37

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

#generate_random(rng, context, args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/synthra/types/address_location/airports.rb', line 8

def generate_random(rng, context, args)
  adapter = faker_adapter(context)
  if adapter && adapter.respond_to?(:airport_name)
    adapter.airport_name

  else
    # Fallback to common airport names
    rng.sample([
      "John F. Kennedy International Airport",
      "Los Angeles International Airport",
      "Heathrow Airport",
      "Charles de Gaulle Airport",
      "Dubai International Airport"
    ])
  end

rescue StandardError
  rng.sample([
    "John F. Kennedy International Airport",
    "Los Angeles International Airport",
    "Heathrow Airport"
  ])
end