witt 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5ee5ade61c2a698b89abacf215cf835eb4a6435
4
- data.tar.gz: 7bd2ae3c28fe2446c4efd91f3de1805becd87955
3
+ metadata.gz: 86c29f07cd0cf564c0a9c81b017ec686e45107b4
4
+ data.tar.gz: f9fb86248a8ee48f0911ecaf836b56d9aaee104a
5
5
  SHA512:
6
- metadata.gz: ce4a3b564004212a530e0c4f135e96054e1c0b4bea288381ece6e2c873b80ec4ba0f330e66f2d856e523dc1e17e205346a1a0e93e013cda825aeb7e30f326aaf
7
- data.tar.gz: 72ce29d9fa0f3e8748c313aaf77782a0c7abe166f50e9b3cae849cf916d57fe69454ec276594a6070b5145e848da3a1ba693080d6c9d5ebc97f2771bde9925d7
6
+ metadata.gz: b4a44ff291ebe24f7573060fc49c65946bf8b2bdcef464d12111f748d85a232b6639181916122cd385c0a84c53bac6c317acd93819fc9e16e4f2b36a50ce4116
7
+ data.tar.gz: 740b1c157746e3ddebf6762a7fd7ecd8c4f63a725c910a51bdceb3ecfdd86a18ce8d356b2aab9399e02eb4f76c3d82d0cc6525c536d6432f5e4b46b062da7ce2
@@ -12,12 +12,19 @@ module Witt
12
12
  world_clock = WorldClock.new
13
13
  output = Output.new
14
14
 
15
+ invalid_airports = []
16
+
15
17
  airports.each do |airport|
16
18
  airport = airport.upcase
17
- timezone = @IATA[airport]
18
- time = world_clock.time_in(timezone)
19
-
20
- output.print(time, airport, timezone)
19
+ timezone = Witt::IATA[airport]
20
+ begin
21
+ time = world_clock.time_in(timezone)
22
+ output.print(time, airport, timezone)
23
+ rescue
24
+ invalid_airports << airport
25
+ end
21
26
  end
27
+
28
+ output.print_error(invalid_airports) unless invalid_airports.empty?
22
29
  end
23
30
  end
@@ -1,6 +1,5 @@
1
1
  module Witt
2
- extend self
3
- @IATA = {
2
+ IATA = {
4
3
  "3BB" => "America/Detroit",
5
4
  "AAA" => "Pacific/Tahiti",
6
5
  "AAB" => "Australia/Brisbane",
@@ -8,6 +8,11 @@ module Witt
8
8
  puts "#{iata_code}: #{emoji} #{formatted_time} (#{timezone})"
9
9
  end
10
10
 
11
+ def print_error(invalid_airports)
12
+ error_message = "\nNo time zone info found for: #{invalid_airports.join(", ")}"
13
+ puts message_in_red(error_message)
14
+ end
15
+
11
16
  private
12
17
 
13
18
  def to_emoji(time)
@@ -18,5 +23,8 @@ module Witt
18
23
  time.hour >= 19 || time.hour <= 5
19
24
  end
20
25
 
26
+ def message_in_red(message)
27
+ "\e[31m#{message}\e[0m"
28
+ end
21
29
  end
22
30
  end
@@ -1,3 +1,3 @@
1
1
  module Witt
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: witt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Vereza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-31 00:00:00.000000000 Z
11
+ date: 2017-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.6.13
106
+ rubygems_version: 2.6.14
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: What Is The Time - Ruby world clock on your terminal