-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added travel folder and airports (#2601)
* added travel folder and airports. I often find myself creating these seeds and would love the addition to Faker to help save time on travel apps. This commit contains us and eu airports by size and iata code * Update test/faker/travel/test_faker_airports.rb Co-authored-by: Stefanni Brasil <stefannibrasil@gmail.com> * Update lib/faker/travel/airport.rb Co-authored-by: Thiago Araujo <thd.araujo@gmail.com> * Update lib/faker/travel/airport.rb Co-authored-by: Thiago Araujo <thd.araujo@gmail.com> * added continent/region argument to generator, this works by name || iata code * fixed white space issue for rubocop * refactored airport md to 2 methods name or iata, both take arguments size && region, provided some rescue for method, and added generator to README Co-authored-by: Stefanni Brasil <stefannibrasil@gmail.com> Co-authored-by: Thiago Araujo <thd.araujo@gmail.com>
- Loading branch information
1 parent
05a5e1e
commit 25d45f6
Showing
5 changed files
with
455 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Faker::Travel::Airport | ||
|
||
```ruby | ||
Faker::Movies::Travel::Airport.name('large', 'united_states') #=> "Los Angeles International Airport" | ||
Faker::Movies::Travel::Airport.iata('large', 'united_states') #=> "LAX" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
module Faker | ||
class Travel | ||
class Airport < Base | ||
class << self | ||
## | ||
# Produces random Airport by name and takes arguments for size and region | ||
# | ||
# @param size [String] airport size, united_states has large, or medium, or small, european_union has large, or medium | ||
# | ||
# @param region [String] airport region, currently available -> united_states or european_union | ||
# | ||
# @retrun [String] | ||
# | ||
# @example | ||
# Faker::Travel::Airport.name('large', 'united_states') => "Los Angeles International Airport" | ||
# | ||
# @faker.version next | ||
def name(size, region) | ||
fetch("airport.#{region}.#{size}") | ||
rescue I18n::MissingTranslationData | ||
p 'valid arguments are size && region -> US has size large medium small, EU has size large medium -- united_states || european_union' | ||
end | ||
|
||
## | ||
# Produces random Airport by IATA code and takes arguments for size and region | ||
# | ||
# @param size [String] airport size, united_states has large, or medium, or small, european_union has large, or medium | ||
# | ||
# @param region [String] airport region, currently available -> united_states or european_union | ||
# | ||
# @retrun [String] | ||
# | ||
# @example | ||
# Faker::Travel::Airport.iata('large', 'united_states') => "LAX" | ||
# | ||
# @faker.version next | ||
def iata(size, region) | ||
fetch("airport.#{region}.iata_code.#{size}") | ||
rescue I18n::MissingTranslationData | ||
p 'valid arguments are size && region -> US has size large medium small, EU has size large medium -- united_states || european_union' | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.