This repository was archived by the owner on Aug 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +36
-30
lines changed Expand file tree Collapse file tree 1 file changed +36
-30
lines changed Original file line number Diff line number Diff line change @@ -9,40 +9,46 @@ def ip_location
9
9
print 'IP => '
10
10
ip = gets . chomp
11
11
12
- begin
13
- url = "http://ip-api.com/json/#{ ip } "
14
- response = RestClient . get ( url )
15
- info = JSON . parse ( response )
16
- rescue
17
- puts ''
18
- puts 'IP not found.'
12
+ if ip == 'quit' || ip == 'exit'
19
13
puts ''
20
14
exit ( 0 )
21
- end
15
+ else
16
+
17
+ begin
18
+ url = "http://ip-api.com/json/#{ ip } "
19
+ response = RestClient . get ( url )
20
+ info = JSON . parse ( response )
21
+ rescue
22
+ puts ''
23
+ puts 'IP not found.'
24
+ puts ''
25
+ exit ( 0 )
26
+ end
22
27
23
- ip = info [ 'query' ]
24
- city = info [ 'city' ]
25
- region = info [ 'region' ]
26
- country = info [ 'country' ]
27
- isp = info [ 'isp' ]
28
- zip = info [ 'zip' ]
28
+ ip = info [ 'query' ]
29
+ city = info [ 'city' ]
30
+ region = info [ 'region' ]
31
+ country = info [ 'country' ]
32
+ isp = info [ 'isp' ]
33
+ zip = info [ 'zip' ]
29
34
30
- if city . nil?
31
- puts ''
32
- puts 'IP not found.'
33
- puts ''
34
- exit ( 0 )
35
- else
36
- puts ''
37
- puts '============================='
38
- puts "| IP: #{ ip } "
39
- puts "| City: #{ city } "
40
- puts "| Region: #{ region } "
41
- puts "| Country: #{ country } "
42
- puts "| ZIP: #{ zip } "
43
- puts "| ISP: #{ isp } "
44
- puts '============================='
45
- puts ''
35
+ if city . nil?
36
+ puts ''
37
+ puts 'IP not found.'
38
+ puts ''
39
+ exit ( 0 )
40
+ else
41
+ puts ''
42
+ puts '============================='
43
+ puts "| IP: #{ ip } "
44
+ puts "| City: #{ city } "
45
+ puts "| Region: #{ region } "
46
+ puts "| Country: #{ country } "
47
+ puts "| ZIP: #{ zip } "
48
+ puts "| ISP: #{ isp } "
49
+ puts '============================='
50
+ puts ''
51
+ end
46
52
end
47
53
end
48
54
You can’t perform that action at this time.
0 commit comments