module FFaker::PhoneNumberJA

Constants

FOUR_DISIT_FORMAT
IP_PHONE_PREFIX
JAPAN_COUNTRY_CODE
JAPAN_PREFIX
MOBILE_NUMBER_FORMAT
MOBILE_PHONE_PREFIXES
ONE_DISIT_FORMAT
THREE_DISIT_FORMAT
TWO_DISIT_FORMAT

Public Instance Methods

home_phone_number() click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 22
def home_phone_number
  disit = rand(1..4)
  FFaker.numerify("#{JAPAN_PREFIX}#{home_phone_number_format(disit)}")
end
home_phone_number_format(disit) click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 63
def home_phone_number_format(disit)
  prefix = home_phone_prefix(disit)
  select_home_phone_format(disit) % prefix
end
home_phone_prefix(disit = nil) click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 54
def home_phone_prefix(disit = nil)
  case disit
  when 1 then fetch_sample(ONE_DISIT_AREA_CODES)
  when 2 then fetch_sample(TWO_DISIT_AREA_CODES)
  when 3 then fetch_sample(THREE_DISIT_AREA_CODES)
  when 4 then fetch_sample(FOUR_DISIT_AREA_CODES)
  end
end
international_home_phone_number() click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 38
def international_home_phone_number
  disit = rand(1..4)
  FFaker.numerify("#{JAPAN_COUNTRY_CODE} #{home_phone_number_format(disit)}")
end
international_mobile_phone_number() click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 43
def international_mobile_phone_number
  FFaker.numerify("#{JAPAN_COUNTRY_CODE} #{mobile_phone_number_format}")
end
international_phone_number() click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 47
def international_phone_number
  case rand(0..1)
  when 0 then international_mobile_phone_number
  when 1 then international_home_phone_number
  end
end
mobile_phone_number() click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 27
def mobile_phone_number
  FFaker.numerify("#{JAPAN_PREFIX}#{mobile_phone_number_format}")
end
mobile_phone_number_format() click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 72
def mobile_phone_number_format
  prefix = mobile_prefix
  MOBILE_NUMBER_FORMAT % prefix
end
mobile_prefix() click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 68
def mobile_prefix
  fetch_sample(MOBILE_PHONE_PREFIXES)
end
phone_number() click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 31
def phone_number
  case rand(0..1)
  when 0 then home_phone_number
  when 1 then mobile_phone_number
  end
end

Private Instance Methods

select_home_phone_format(disit) click to toggle source
# File lib/ffaker/phone_number_ja.rb, line 79
def select_home_phone_format(disit)
  case disit
  when 1 then ONE_DISIT_FORMAT
  when 2 then TWO_DISIT_FORMAT
  when 3 then THREE_DISIT_FORMAT
  when 4 then FOUR_DISIT_FORMAT
  end
end