インストール
1 2 3 |
group :development do gem 'faker' end |
構文
1 |
Faker::[ジャンル].[タイトルなど] |
どんなジャンルがあるか調べるには?
githubの以下のページに行けば一覧で使えるジャンルのクラスが記載してあります。
1 |
https://github.com/faker-ruby/faker |
例
Movie
1 2 3 4 5 6 |
irb(main):003:0> Faker::Movie.title => "Star Wars: Episode II – Attack of the Clones" irb(main):004:0> Faker::Movie.title => "The Intouchables" irb(main):005:0> Faker::Movie.title => "Hotel Rwanda" |
Pokemon
1 2 3 4 |
irb(main):017:0> Faker::Games::Pokemon.name => "Graveler" irb(main):018:0> Faker::Games::Pokemon.name => "Nidorina" |
Book
1 2 3 4 |
irb(main):027:0> Faker::Book.title => "Mother Night" irb(main):028:0> Faker::Book.title => "All the King's Men" |
日本語化
1 2 3 4 5 |
Faker::Config.locale = :ja irb(main):044:0> Faker::Address.city => "新井郡" irb(main):045:0> Faker::Address.city => "陸町" |
実務を意識するなら
実務で実際に使うなら以下のようなデータが使えるでしょう。
- 住所
- 名前
- メールアドレス
この記事へのコメントはありません。