Module: PostcodeThreeCountry
- Defined in:
- lib/postcode_three_country.rb,
lib/postcode_three_country/version.rb
Constant Summary collapse
- VERSION =
"0.1.4"
Class Method Summary collapse
-
.eng_city_find_postcode(find_postcode) ⇒ Object
Xử lý khi tìm Postcode bằng tên thành phố của Vietnam.
- .eng_country ⇒ Object
-
.eng_postcode_find_city(find_city) ⇒ Object
Xử lý khi tìm tên thành phố bằng Postcode của England.
- .hello ⇒ Object
-
.jp_city_find_postcode(find_postcode) ⇒ Object
Xử lý khi tìm Postcode bằng tên thành phố của Japan.
- .jp_country ⇒ Object
-
.jp_postcode_find_city(find_city) ⇒ Object
Xử lý khi tìm tên thành phố bằng Postcode của Japan.
-
.vi_city_find_postcode(find_postcode) ⇒ Object
Xử lý khi tìm Postcode bằng tên thành phố của Vietnam.
- .vi_country ⇒ Object
-
.vi_postcode_find_city(find_city) ⇒ Object
Xử lý khi tìm tên thành phố bằng Postcode của Việt Nam.
Class Method Details
.eng_city_find_postcode(find_postcode) ⇒ Object
Xử lý khi tìm Postcode bằng tên thành phố của Vietnam
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/postcode_three_country.rb', line 141 def self.eng_city_find_postcode find_postcode eng_country array_country = @eng_postcode['england'].values find_postcode = find_postcode.gsub(/[\W\d]/, '') first_word = find_postcode.split('')[0] array_postcode = [] array_city = [] array_country.each do |country| array_postcode << country.values[0] array_city << country.values[1] end if array_city.include?(find_postcode) array_country.each do |postcode| puts postcode.values[0] if postcode.has_value?(find_postcode) end else puts array_city.map { |v| puts v if v.start_with?(first_word) } end # binding.pry end |
.eng_country ⇒ Object
19 20 21 |
# File 'lib/postcode_three_country.rb', line 19 def self.eng_country @eng_postcode = YAML::load_file(File.join(__dir__, "data/england_zipcode.yaml")) end |
.eng_postcode_find_city(find_city) ⇒ Object
Xử lý khi tìm tên thành phố bằng Postcode của England
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/postcode_three_country.rb', line 70 def self.eng_postcode_find_city find_city eng_country array_country = @eng_postcode['england'].values find_city = find_city.gsub(/\D/, '') first_word = find_city.split('')[0] array_postcode = [] array_city = [] array_country.each do |country| array_postcode << country.values[0] array_city << country.values[1] end if array_postcode.include?(find_city) array_country.each do |city| puts city.values[1] if city.has_value?(find_city) end else puts array_postcode.map { |v| puts v if v.start_with?(first_word) } end end |
.hello ⇒ Object
7 8 9 |
# File 'lib/postcode_three_country.rb', line 7 def self.hello puts "Hello from Postcode" end |
.jp_city_find_postcode(find_postcode) ⇒ Object
Xử lý khi tìm Postcode bằng tên thành phố của Japan
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/postcode_three_country.rb', line 117 def self.jp_city_find_postcode find_postcode jp_country array_country = @jp_postcode['japan'].values find_postcode = find_postcode.gsub(/[\W\d]/, '') first_word = find_postcode.split('')[0] array_postcode = [] array_city = [] array_country.each do |country| array_postcode << country.values[0] array_city << country.values[1] end if array_city.include?(find_postcode) array_country.each do |postcode| puts postcode.values[0] if postcode.has_value?(find_postcode) end else puts array_city.map { |v| puts v if v.start_with?(first_word) } end # binding.pry end |
.jp_country ⇒ Object
15 16 17 |
# File 'lib/postcode_three_country.rb', line 15 def self.jp_country @jp_postcode = YAML::load_file(File.join(__dir__, "data/japan_zipcode.yaml")) end |
.jp_postcode_find_city(find_city) ⇒ Object
Xử lý khi tìm tên thành phố bằng Postcode của Japan
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/postcode_three_country.rb', line 47 def self.jp_postcode_find_city find_city jp_country array_country = @jp_postcode['japan'].values find_city = find_city.gsub(/\D/, '') first_word = find_city.split('')[0] array_postcode = [] array_city = [] array_country.each do |country| array_postcode << country.values[0] array_city << country.values[1] end if array_postcode.include?(find_city) array_country.each do |city| puts city.values[1] if city.has_value?(find_city) end else puts array_postcode.map { |v| puts v if v.start_with?(first_word) } end end |
.vi_city_find_postcode(find_postcode) ⇒ Object
Xử lý khi tìm Postcode bằng tên thành phố của Vietnam
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/postcode_three_country.rb', line 93 def self.vi_city_find_postcode find_postcode vi_country array_country = @vi_postcode['vietnam'].values find_postcode = find_postcode.gsub(/[\W\d]/, '') first_word = find_postcode.split('')[0] array_postcode = [] array_city = [] array_country.each do |country| array_postcode << country.values[0] array_city << country.values[1] end if array_city.include?(find_postcode) array_country.each do |postcode| puts postcode.values[0] if postcode.has_value?(find_postcode) end else # binding.pry puts array_city.map { |v| puts v if v.start_with?(first_word) } end end |
.vi_country ⇒ Object
11 12 13 |
# File 'lib/postcode_three_country.rb', line 11 def self.vi_country @vi_postcode = YAML::load_file(File.join(__dir__, "data/vietnam_zipcode.yaml")) end |
.vi_postcode_find_city(find_city) ⇒ Object
Xử lý khi tìm tên thành phố bằng Postcode của Việt Nam
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/postcode_three_country.rb', line 24 def self.vi_postcode_find_city find_city vi_country array_country = @vi_postcode['vietnam'].values find_city = find_city.gsub(/\D/, '') first_word = find_city.split('')[0] array_postcode = [] array_city = [] array_country.each do |country| array_postcode << country.values[0] array_city << country.values[1] end if array_postcode.include?(find_city) array_country.each do |city| puts city.values[1] if city.has_value?(find_city) end else puts array_postcode.map { |v| puts v if v.start_with?(first_word) } end end |