witt 0.1.0 → 0.2.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/README.md +13 -20
- data/bin/witt +2 -1
- data/lib/witt/iata.rb +9146 -0
- data/lib/witt/output.rb +22 -0
- data/lib/witt/version.rb +1 -1
- data/lib/witt/world_clock.rb +1 -4
- data/lib/witt.rb +19 -0
- metadata +7 -4
data/lib/witt/output.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Witt
|
2
|
+
class Output
|
3
|
+
|
4
|
+
def print(time, iata_code, timezone)
|
5
|
+
formatted_time = time.strftime("%b %e, %H:%M")
|
6
|
+
emoji = to_emoji(time)
|
7
|
+
|
8
|
+
puts "#{iata_code}: #{emoji} #{formatted_time} (#{timezone})"
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def to_emoji(time)
|
14
|
+
is_evening?(time) ? "🌘 " : "☀️ "
|
15
|
+
end
|
16
|
+
|
17
|
+
def is_evening?(time)
|
18
|
+
time.hour >= 19 || time.hour <= 5
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/witt/version.rb
CHANGED
data/lib/witt/world_clock.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
module Witt
|
2
2
|
class WorldClock
|
3
|
-
def initialize(clock = Time)
|
4
|
-
@clock = clock
|
5
|
-
end
|
6
3
|
|
7
4
|
def time_in(time_zone)
|
8
5
|
tzinfo = TZInfo::Timezone.get(time_zone)
|
@@ -10,7 +7,7 @@ module Witt
|
|
10
7
|
|
11
8
|
offset = period.offset.utc_total_offset
|
12
9
|
|
13
|
-
|
10
|
+
Time.now.getlocal(offset)
|
14
11
|
end
|
15
12
|
end
|
16
13
|
end
|
data/lib/witt.rb
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
require "tzinfo"
|
2
2
|
|
3
3
|
require "witt/version"
|
4
|
+
require "witt/iata"
|
4
5
|
require "witt/world_clock"
|
6
|
+
require "witt/output"
|
7
|
+
|
8
|
+
module Witt
|
9
|
+
extend self
|
10
|
+
|
11
|
+
def time_in(airports)
|
12
|
+
world_clock = WorldClock.new
|
13
|
+
output = Output.new
|
14
|
+
|
15
|
+
airports.each do |airport|
|
16
|
+
airport = airport.upcase
|
17
|
+
timezone = @IATA[airport]
|
18
|
+
time = world_clock.time_in(timezone)
|
19
|
+
|
20
|
+
output.print(time, airport, timezone)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2017-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -66,7 +66,8 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
-
description:
|
69
|
+
description: Quickly check current time in different timezones without leaving your
|
70
|
+
beloved terminal.
|
70
71
|
email:
|
71
72
|
- pdrvereza@gmail.com
|
72
73
|
executables:
|
@@ -78,6 +79,8 @@ files:
|
|
78
79
|
- README.md
|
79
80
|
- bin/witt
|
80
81
|
- lib/witt.rb
|
82
|
+
- lib/witt/iata.rb
|
83
|
+
- lib/witt/output.rb
|
81
84
|
- lib/witt/version.rb
|
82
85
|
- lib/witt/world_clock.rb
|
83
86
|
homepage: https://github.com/pedrovereza/witt
|
@@ -103,5 +106,5 @@ rubyforge_project:
|
|
103
106
|
rubygems_version: 2.6.13
|
104
107
|
signing_key:
|
105
108
|
specification_version: 4
|
106
|
-
summary: Ruby world clock on your terminal
|
109
|
+
summary: What Is The Time - Ruby world clock on your terminal
|
107
110
|
test_files: []
|