class Faker::Travel::TrainStation
def fill_missing_inputs_with_samples(region, type)
def fill_missing_inputs_with_samples(region, type) regions = %w[germany spain united_kingdom united_states] types = %w[metro railway] if region.nil? && type.nil? region = sample(regions) type = sample(types) elsif region.nil? validate_arguments(type, types, 'type') region = sample(regions) elsif type.nil? validate_arguments(region, regions, 'region') type = sample(types) end [region, type] end
def name(region: nil, type: nil)
-
(String)
-
Parameters:
-
type
(String
) -- Train station type: metro, railway -
region
(String
) -- Train station region: germany, spain, united_kingdom, united_states
def name(region: nil, type: nil) region, type = fill_missing_inputs_with_samples(region, type) fetch("train_station.#{region}.#{type}") end
def validate_arguments(argument, correct_values, argument_name)
def validate_arguments(argument, correct_values, argument_name) return if correct_values.include?(argument) raise ArgumentError, "'#{argument}' not found, #{argument_name} can be blank, or one of the following, as strings: #{correct_values.join(', ')}" end