postcode_gem 0.2.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/postcode_gem/version.rb +1 -1
- data/lib/postcode_gem.rb +2 -36
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5294f1ef91e202e42f4f232a5754bcf93c923c94671d6748a5745f2a397c6399
|
|
4
|
+
data.tar.gz: 6233cc4caf095e48997ca21aab7042c89445ca51f31e7ec378cb1002304a9374
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8feed077e8ee14d610342e8053f1756c235c3480be5f95aecb2c788003fbc925121db38ac9e9dee818f4d58cec2c28d447428ac360115ee6805d90f5ec8a0044
|
|
7
|
+
data.tar.gz: 9634aabc75264740941aa9c5f625563683bb3a55facbbb67b4fbba6316abe646b736ef43407acdcaa364afa32be301714f3ae4768fe231d6a349cc50d4f403a1
|
data/lib/postcode_gem/version.rb
CHANGED
data/lib/postcode_gem.rb
CHANGED
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
require "tty-prompt"
|
|
3
|
-
require "pry"
|
|
1
|
+
require_relative '../lib/postcode_gem/handle'
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
module PostcodeGem
|
|
7
|
-
def self.select_country
|
|
8
|
-
@data = JSON.load(File.read('./data/postcode_areacode.json'))
|
|
9
|
-
attr_accessor :country, :city, :zipcode
|
|
10
|
-
prompt = TTY::Prompt.new
|
|
11
|
-
@country = prompt.select('Enter the country you want to select', %w(Vietnam England Japan))
|
|
12
|
-
end
|
|
13
|
-
def self.process_input
|
|
14
|
-
select_country
|
|
15
|
-
print "Enter the city or area code you want to search: "
|
|
16
|
-
@city_zipcode = gets.chomp
|
|
17
|
-
@firstWord = @city_zipcode.split('')[0]
|
|
18
|
-
end
|
|
19
|
-
def output_zipcode
|
|
20
|
-
process_input
|
|
21
|
-
@city = @data["#{@country}"].values
|
|
22
|
-
@zipcode = @data["#{@country}"].keys
|
|
23
|
-
@data_country = @data["#{@country}"]
|
|
24
|
-
|
|
25
|
-
if @data_country.has_key?(@city_zipcode)
|
|
26
|
-
puts @data_country.values_at("#{@city_zipcode}")
|
|
27
|
-
elsif @data_country.has_key?(@city_zipcode) == false && /[0-9]/.match(@firstWord)
|
|
28
|
-
puts @zipcode.map { |v| puts v if v.start_with?(@firstWord) }
|
|
29
|
-
end
|
|
30
|
-
if @data_country.has_value?(@city_zipcode)
|
|
31
|
-
puts @data_country.key(@city_zipcode)
|
|
32
|
-
elsif @data_country.has_value?(@city_zipcode) == false && /[a-z]/.match(@firstWord)
|
|
33
|
-
puts @city.map { |v| puts v if v.start_with?(@firstWord) }
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
module_function :output_zipcode
|
|
37
|
-
end
|
|
3
|
+
PostcodeGem::Handle.new.output_zipcode
|