Skip to content

Instantly share code, notes, and snippets.

@tlikai
Created September 30, 2016 02:17
Show Gist options
  • Save tlikai/3838c5b2da7b03a95120980e901d4461 to your computer and use it in GitHub Desktop.
Save tlikai/3838c5b2da7b03a95120980e901d4461 to your computer and use it in GitHub Desktop.
Ruby Faker::PhoneNumber 生成国内手机号
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