Created
September 30, 2016 02:17
-
-
Save tlikai/3838c5b2da7b03a95120980e901d4461 to your computer and use it in GitHub Desktop.
Ruby Faker::PhoneNumber 生成国内手机号
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
module Faker | |
class PhoneNumber < Base | |
class << self | |
def cell_phone | |
operators = [ | |
134, 135, 136, 137, 138, 139, 147, 150, 151, 152, 157, 158, 159, 182, 187, 188, # china mobile | |
130, 131, 132, 145, 155, 156, 185, 186, 145, # china unicom | |
133, 153, 180, 181, 189 # china telecom | |
] | |
suffix = Random.rand(10000000...99999999) | |
"#{operators.sample}#{suffix}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment