Module: FFakerTW::AddressTW
Constant Summary collapse
- CITY_NAMES =
%w[基隆市 台北市 新北市 桃園市 新竹市 新竹縣 苗栗縣 台中市 彰化縣 南投縣 雲林縣 嘉義市 嘉義縣 台南市 高雄市 屏東縣 宜蘭縣 花蓮縣 台東縣 澎湖縣 金門縣 連江縣].freeze
Instance Method Summary collapse
-
#changhua ⇒ Object
彰化縣.
-
#chiayi ⇒ Object
嘉義縣市.
-
#city ⇒ Object
縣市.
-
#hsinchu ⇒ Object
新竹縣市.
-
#hualien ⇒ Object
花蓮縣.
-
#kaohsiung ⇒ Object
高雄市.
-
#keelung ⇒ Object
基隆市.
-
#kingmen ⇒ Object
金門縣.
-
#miaoli ⇒ Object
苗栗縣.
-
#name ⇒ Object
完整地址(縣市+鄉鎮市區+路/街+段+巷+弄+號+樓.
-
#nantou ⇒ Object
南投縣.
-
#newtaipei ⇒ Object
新北市.
-
#penghu ⇒ Object
澎湖縣.
-
#pingtung ⇒ Object
屏東市.
-
#road ⇒ Object
縣市鄉鎮+路名(無號碼).
-
#taichung ⇒ Object
台中市.
-
#tainan ⇒ Object
台南市.
-
#taipei ⇒ Object
台北市.
-
#taitung ⇒ Object
台東縣.
-
#taoyuan ⇒ Object
桃園市.
-
#yilan ⇒ Object
宜蘭縣.
-
#yunlin ⇒ Object
雲林縣.
Methods included from ModuleUtils
const_missing, k, luhn_check, underscore, unique
Methods included from RandomUtils
#fetch_sample, #rand, #shuffle
Instance Method Details
#changhua ⇒ Object
彰化縣
59 60 61 |
# File 'lib/ffakerTW/address_tw.rb', line 59 def changhua #彰化縣 "#{fetch_sample(CHANGHUA)}#{rand(1..300)}號" end |
#chiayi ⇒ Object
嘉義縣市
71 72 73 |
# File 'lib/ffakerTW/address_tw.rb', line 71 def chiayi #嘉義縣市 "#{fetch_sample(CHIAYI)}#{rand(1..300)}號" end |
#city ⇒ Object
縣市
107 108 109 |
# File 'lib/ffakerTW/address_tw.rb', line 107 def city #縣市 fetch_sample(CITY_NAMES) end |
#hsinchu ⇒ Object
新竹縣市
47 48 49 |
# File 'lib/ffakerTW/address_tw.rb', line 47 def hsinchu #新竹縣市 "#{fetch_sample(HSINCHU)}#{rand(1..300)}號" end |
#hualien ⇒ Object
花蓮縣
95 96 97 |
# File 'lib/ffakerTW/address_tw.rb', line 95 def hualien #花蓮縣 "#{fetch_sample(HUALIEN)}#{rand(1..300)}號" end |
#kaohsiung ⇒ Object
高雄市
79 80 81 |
# File 'lib/ffakerTW/address_tw.rb', line 79 def kaohsiung #高雄市 "#{fetch_sample(KAOHSIUNG)}#{rand(1..300)}號" end |
#keelung ⇒ Object
基隆市
39 40 41 |
# File 'lib/ffakerTW/address_tw.rb', line 39 def keelung #基隆市 "#{fetch_sample(KEELUNG)}#{rand(1..300)}號" end |
#kingmen ⇒ Object
金門縣
103 104 105 |
# File 'lib/ffakerTW/address_tw.rb', line 103 def kingmen #金門縣 "#{fetch_sample(KINGMEN)}#{rand(1..300)}號" end |
#miaoli ⇒ Object
苗栗縣
51 52 53 |
# File 'lib/ffakerTW/address_tw.rb', line 51 def miaoli #苗栗縣 "#{fetch_sample(MIAOLI)}#{rand(1..300)}號" end |
#name ⇒ Object
完整地址(縣市+鄉鎮市區+路/街+段+巷+弄+號+樓
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 |
#nantou ⇒ Object
南投縣
63 64 65 |
# File 'lib/ffakerTW/address_tw.rb', line 63 def nantou #南投縣 "#{fetch_sample(NANTOU)}#{rand(1..300)}號" end |
#newtaipei ⇒ Object
新北市
35 36 37 |
# File 'lib/ffakerTW/address_tw.rb', line 35 def newtaipei #新北市 "#{fetch_sample(NEWTAIPEI)}#{rand(1..300)}號" end |
#penghu ⇒ Object
澎湖縣
87 88 89 |
# File 'lib/ffakerTW/address_tw.rb', line 87 def penghu #澎湖縣 "#{fetch_sample(PENGHU)}#{rand(1..300)}號" end |
#pingtung ⇒ Object
屏東市
83 84 85 |
# File 'lib/ffakerTW/address_tw.rb', line 83 def pingtung #屏東市 "#{fetch_sample(PINGTUNG)}#{rand(1..300)}號" end |
#road ⇒ Object
縣市鄉鎮+路名(無號碼)
111 112 113 |
# File 'lib/ffakerTW/address_tw.rb', line 111 def road #縣市鄉鎮+路名(無號碼) fetch_sample(ALL) end |
#taichung ⇒ Object
台中市
55 56 57 |
# File 'lib/ffakerTW/address_tw.rb', line 55 def taichung #台中市 "#{fetch_sample(TAICHUNG)}#{rand(1..300)}號" end |
#tainan ⇒ Object
台南市
75 76 77 |
# File 'lib/ffakerTW/address_tw.rb', line 75 def tainan #台南市 "#{fetch_sample(TAINAN)}#{rand(1..300)}號" end |
#taipei ⇒ Object
台北市
31 32 33 |
# File 'lib/ffakerTW/address_tw.rb', line 31 def taipei #台北市 "#{fetch_sample(TAIPEI)}#{rand(1..300)}號" end |
#taitung ⇒ Object
台東縣
99 100 101 |
# File 'lib/ffakerTW/address_tw.rb', line 99 def taitung #台東縣 "#{fetch_sample(TAITUNG)}#{rand(1..300)}號" end |
#taoyuan ⇒ Object
桃園市
43 44 45 |
# File 'lib/ffakerTW/address_tw.rb', line 43 def taoyuan #桃園市 "#{fetch_sample(TAOYUAN)}#{rand(1..300)}號" end |
#yilan ⇒ Object
宜蘭縣
91 92 93 |
# File 'lib/ffakerTW/address_tw.rb', line 91 def yilan #宜蘭縣 "#{fetch_sample(YILAN)}#{rand(1..300)}號" end |
#yunlin ⇒ Object
雲林縣
67 68 69 |
# File 'lib/ffakerTW/address_tw.rb', line 67 def yunlin #雲林縣 "#{fetch_sample(YUNLIN)}#{rand(1..300)}號" end |