File: address_kr.rb

package info (click to toggle)
ruby-ffaker 2.23.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,776 kB
  • sloc: ruby: 12,788; makefile: 8; sh: 1
file content (87 lines) | stat: -rw-r--r-- 2,561 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# frozen_string_literal: true

module FFaker
  module AddressKR
    extend ModuleUtils
    extend self

    BUILDING_DONGS = %w[가 나 다 라 마 바 ## ###].freeze
    BUILDING_SUFFIXES = %w[빌라 아파트 연립 마을 타운 타워].freeze
    STREET_SUFFIXES = %w[로 #로 가 #가 거리 길].freeze
    TOWN_SUFFIXES = %w[동 리 마을].freeze
    METROPOLITAN_CITIES = %w[서울특별시 부산광역시 대구광역시 인천광역시
                             광주광역시 대전광역시 울산광역시 세종특별자치시].freeze
    PROVINCES = %w[경기도 강원도 충청북도 충청남도 전라북도 전라남도 경상북도
                   경상남도 제주특별자치도].freeze

    def postal_code
      FFaker.numerify('#####')
    end

    def old_postal_code
      FFaker.numerify('###-###')
    end

    def road_addess
      fetch_sample([
                     "#{metropolitan_city} #{borough} #{street}",
                     "#{province} #{town} #{street}",
                     "#{metropolitan_city} #{borough} #{street} (#{town})",
                     "#{province} #{town} #{street} (#{town})"
                   ])
    end

    def land_address
      fetch_sample([
                     "#{metropolitan_city} #{borough} #{town} #{land_number}",
                     "#{province} #{town} #{land_number}"
                   ])
    end

    def land_number
      FFaker.numerify(fetch_sample([
                                     '###',
                                     '###-#',
                                     '###-##',
                                     '####',
                                     '####-#'
                                   ]))
    end

    def building_name
      "#{NameKR.first_name}#{fetch_sample(BUILDING_SUFFIXES)}"
    end

    def address_detail
      FFaker.numerify(fetch_sample([
                                     building_name,
                                     "#{building_name} ###호",
                                     "#{building_name} #{fetch_sample(BUILDING_DONGS)} ###호"
                                   ]))
    end

    def street
      FFaker.numerify("#{NameKR.first_name}#{fetch_sample(STREET_SUFFIXES)}")
    end

    def town
      "#{NameKR.first_name}#{fetch_sample(TOWN_SUFFIXES)}"
    end

    def borough
      fetch_sample(BOROUGHS)
    end

    def city
      fetch_sample(CITIES)
    end

    def province
      fetch_sample(PROVINCES)
    end

    def metropolitan_city
      fetch_sample(METROPOLITAN_CITIES)
    end
  end
end