Module: FFakerTW::AddressTW

Extended by:
AddressTW, ModuleUtils
Included in:
AddressTW
Defined in:
lib/ffakerTW/address_tw.rb

Constant Summary collapse

CITY_NAMES =
%w[基隆市 台北市 新北市 桃園市 新竹市 新竹縣 苗栗縣 台中市 彰化縣 南投縣 雲林縣 嘉義市 嘉義縣 台南市 高雄市 屏東縣 宜蘭縣 花蓮縣 台東縣 澎湖縣 金門縣 連江縣].freeze

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, luhn_check, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#changhuaObject

彰化縣



59
60
61
# File 'lib/ffakerTW/address_tw.rb', line 59

def changhua  #彰化縣
  "#{fetch_sample(CHANGHUA)}#{rand(1..300)}"
end

#chiayiObject

嘉義縣市



71
72
73
# File 'lib/ffakerTW/address_tw.rb', line 71

def chiayi  #嘉義縣市
  "#{fetch_sample(CHIAYI)}#{rand(1..300)}"
end

#cityObject

縣市



107
108
109
# File 'lib/ffakerTW/address_tw.rb', line 107

def city  #縣市
  fetch_sample(CITY_NAMES)
end

#hsinchuObject

新竹縣市



47
48
49
# File 'lib/ffakerTW/address_tw.rb', line 47

def hsinchu  #新竹縣市
  "#{fetch_sample(HSINCHU)}#{rand(1..300)}"
end

#hualienObject

花蓮縣



95
96
97
# File 'lib/ffakerTW/address_tw.rb', line 95

def hualien  #花蓮縣
  "#{fetch_sample(HUALIEN)}#{rand(1..300)}"
end

#kaohsiungObject

高雄市



79
80
81
# File 'lib/ffakerTW/address_tw.rb', line 79

def kaohsiung  #高雄市
  "#{fetch_sample(KAOHSIUNG)}#{rand(1..300)}"
end

#keelungObject

基隆市



39
40
41
# File 'lib/ffakerTW/address_tw.rb', line 39

def keelung  #基隆市
  "#{fetch_sample(KEELUNG)}#{rand(1..300)}"
end

#kingmenObject

金門縣



103
104
105
# File 'lib/ffakerTW/address_tw.rb', line 103

def kingmen  #金門縣
  "#{fetch_sample(KINGMEN)}#{rand(1..300)}"
end

#miaoliObject

苗栗縣



51
52
53
# File 'lib/ffakerTW/address_tw.rb', line 51

def miaoli  #苗栗縣
  "#{fetch_sample(MIAOLI)}#{rand(1..300)}"
end

#nameObject

完整地址(縣市+鄉鎮市區+路/街+段+巷+弄+號+樓



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ffakerTW/address_tw.rb', line 8

def name  #完整地址(縣市+鄉鎮市區+路/街+段+巷+弄+號+樓
  address = fetch_sample(ALL)  #隨機抓取全省地址
  lane = rand(1..99).to_s + ""  #巷
  alley = rand(1..9).to_s + ""  #弄
  case rand(0..9)
  when 0..1 then "#{address}#{rand(1..500)}"  #路+號
  when 2..3 then
    if address.match(/[路]/)  #是路才有段
      case rand(1..4)
      when 1 then "#{address}一段#{rand(1..500)}"  #路+段+號
      when 2 then "#{address}二段#{rand(1..500)}"
      when 3 then "#{address}三段#{rand(1..500)}"
      when 4 then "#{address}四段#{rand(1..500)}"
      end
    else
      "#{address}#{rand(1..500)}"
    end
  when 4..6 then "#{address}#{rand(1..300)}#{rand(1..10)}F"  #路+號+樓
  when 7..8 then "#{address}#{lane}#{rand(1..40)}"  #路+巷+號
  when 9 then "#{address}#{lane}#{alley}#{rand(1..10)}"  #路+巷+弄+號
  end
end

#nantouObject

南投縣



63
64
65
# File 'lib/ffakerTW/address_tw.rb', line 63

def nantou  #南投縣
  "#{fetch_sample(NANTOU)}#{rand(1..300)}"
end

#newtaipeiObject

新北市



35
36
37
# File 'lib/ffakerTW/address_tw.rb', line 35

def newtaipei  #新北市
  "#{fetch_sample(NEWTAIPEI)}#{rand(1..300)}"
end

#penghuObject

澎湖縣



87
88
89
# File 'lib/ffakerTW/address_tw.rb', line 87

def penghu  #澎湖縣
  "#{fetch_sample(PENGHU)}#{rand(1..300)}"
end

#pingtungObject

屏東市



83
84
85
# File 'lib/ffakerTW/address_tw.rb', line 83

def pingtung  #屏東市
  "#{fetch_sample(PINGTUNG)}#{rand(1..300)}"
end

#roadObject

縣市鄉鎮+路名(無號碼)



111
112
113
# File 'lib/ffakerTW/address_tw.rb', line 111

def road  #縣市鄉鎮+路名(無號碼)
  fetch_sample(ALL)
end

#taichungObject

台中市



55
56
57
# File 'lib/ffakerTW/address_tw.rb', line 55

def taichung  #台中市
  "#{fetch_sample(TAICHUNG)}#{rand(1..300)}"
end

#tainanObject

台南市



75
76
77
# File 'lib/ffakerTW/address_tw.rb', line 75

def tainan  #台南市
  "#{fetch_sample(TAINAN)}#{rand(1..300)}"
end

#taipeiObject

台北市



31
32
33
# File 'lib/ffakerTW/address_tw.rb', line 31

def taipei  #台北市
  "#{fetch_sample(TAIPEI)}#{rand(1..300)}"
end

#taitungObject

台東縣



99
100
101
# File 'lib/ffakerTW/address_tw.rb', line 99

def taitung  #台東縣
  "#{fetch_sample(TAITUNG)}#{rand(1..300)}"
end

#taoyuanObject

桃園市



43
44
45
# File 'lib/ffakerTW/address_tw.rb', line 43

def taoyuan  #桃園市
  "#{fetch_sample(TAOYUAN)}#{rand(1..300)}"
end

#yilanObject

宜蘭縣



91
92
93
# File 'lib/ffakerTW/address_tw.rb', line 91

def yilan  #宜蘭縣
  "#{fetch_sample(YILAN)}#{rand(1..300)}"
end

#yunlinObject

雲林縣



67
68
69
# File 'lib/ffakerTW/address_tw.rb', line 67

def yunlin  #雲林縣
  "#{fetch_sample(YUNLIN)}#{rand(1..300)}"
end