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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc26ff41135c959a98c159074aa03d3be0d54fbb2a8b030877425348fd78ce83
4
- data.tar.gz: ad6a27f321e5393315daf2e0025b8f3eac159e8763c89d26c527819d09c80d19
3
+ metadata.gz: 5294f1ef91e202e42f4f232a5754bcf93c923c94671d6748a5745f2a397c6399
4
+ data.tar.gz: 6233cc4caf095e48997ca21aab7042c89445ca51f31e7ec378cb1002304a9374
5
5
  SHA512:
6
- metadata.gz: ba611119459ac97fd22e35898a4f28c1c27f65444aa7833b475886773e43d58539a0649a1e68f2a24343387c04a4d1a91595b4752cd30cc5d130927e84aa934d
7
- data.tar.gz: 6ebd2f0aad455c8e431c94b6b355aee2cca650f8fa445687b15d8c122fc7478cfaa2e81e5b1c667a8541726e57ab3063bdf364e58c96073242155806f099de4a
6
+ metadata.gz: 8feed077e8ee14d610342e8053f1756c235c3480be5f95aecb2c788003fbc925121db38ac9e9dee818f4d58cec2c28d447428ac360115ee6805d90f5ec8a0044
7
+ data.tar.gz: 9634aabc75264740941aa9c5f625563683bb3a55facbbb67b4fbba6316abe646b736ef43407acdcaa364afa32be301714f3ae4768fe231d6a349cc50d4f403a1
@@ -1,3 +1,3 @@
1
1
  module PostcodeGem
2
- VERSION = "0.2.9"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/postcode_gem.rb CHANGED
@@ -1,37 +1,3 @@
1
- require "json"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postcode_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PhuongTr1501