a_moment_ago 1.1.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/time_ago.rb +45 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7250cc49699475e2ab1480ca15d8d08df7ab71e9112a5dfbb7ff4d2dc5cca5d6
4
+ data.tar.gz: 06fff791f9d4dc775f4ab44e055c3bce027af0d8073aeef04c06e62ff29f60a6
5
+ SHA512:
6
+ metadata.gz: 76e54adbdd4b01a671788a9ad77bfd31934508ea4263abd71637ab41c2c5885be14552c2a17bebce7db3ed230c6b0a1e01f7aac8a21e8eb3587b4caf5ac3a1e8
7
+ data.tar.gz: 7615cd2437f4585011bfb80499723436a5e40f888b80eca4b662bc34335957018eac62688f748ef07c92dbd4b4f11eb1aa772c81b0dab183ca04cbcfad9befaf
data/lib/time_ago.rb ADDED
@@ -0,0 +1,45 @@
1
+ class TimeAgo
2
+ def initialize
3
+ @now = Time.now
4
+ end
5
+
6
+ def time_ago
7
+ time = ""
8
+ if @now.sec === 0
9
+ time = "just now"
10
+ elsif @now.sec < 60
11
+ time = @now.sec.to_s + " seconds ago"
12
+ elsif @now.min === 0
13
+ time = @now.hour.to_s + " hours ago"
14
+ elsif @now.min < 60
15
+ time = @now.min.to_s + " minutes ago"
16
+ elsif @now.hour === 0
17
+ time = "today at " + @now.hour.to_s + ":" + @now.min.to_s
18
+ elsif @now.hour < 24
19
+ time = @now.hour.to_s + " hours ago"
20
+ elsif @now.day === 0
21
+ time = "yesterday at " + @now.hour.to_s + ":" + @now.min.to_s
22
+ elsif @now.day === 1
23
+ time = "Monday at " + @now.hour.to_s + ":" + @now.min.to_s
24
+ elsif @now.day === 2
25
+ time = "Tuesday at " + @now.hour.to_s + ":" + @now.min.to_s
26
+ elsif @now.day === 3
27
+ time = "Wednesday at " + @now.hour.to_s + ":" + @now.min.to_s
28
+ elsif @now.day === 4
29
+ time = "Thursday at " + @now.hour.to_s + ":" + @now.min.to_s
30
+ elsif @now.day === 5
31
+ time = "Friday at " + @now.hour.to_s + ":" + @now.min.to_s
32
+ elsif @now.day === 6
33
+ time = "Saturday at " + @now.hour.to_s + ":" + @now.min.to_s
34
+ elsif @now.day === 7
35
+ time = "Sunday at " + @now.hour.to_s + ":" + @now.min.to_s
36
+ else
37
+ time = "on " + @now.strftime("%A") + " at " + @now.hour.to_s + ":" + @now.min.to_s
38
+ end
39
+
40
+ puts "#{time}!"
41
+ end
42
+ end
43
+
44
+ created = TimeAgo.new
45
+ created.time_ago
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: a_moment_ago
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Webster Avosa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Rendering time in words, e.g. 'just now', '1 minute ago', '2 hours ago',
14
+ etc.
15
+ email: webster@simplyvirtual.io
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/time_ago.rb
21
+ homepage: https://rubygems.org/gems/hola
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.2.3
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Rendering time in words
44
+ test_files: []