Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added travel folder and airports #2601

Merged
merged 15 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
### Fantasy
- [Faker::Fantasy::Tolkien](doc/fantasy/tolkien.md)

### Travel
- [Faker:Travel::Airport](doc/travel/airport.md)

Comment on lines +241 to +243
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

### Creature
- [Faker::Creature::Animal](doc/creature/animal.md)
- [Faker::Creature::Bird](doc/creature/bird.md)
Expand Down
6 changes: 6 additions & 0 deletions doc/travel/airport.md
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"
```
47 changes: 47 additions & 0 deletions lib/faker/travel/airport.rb
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
Loading