clocked 0.0.1 → 0.0.2

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: a5cb23d9c15274667a7f193c1bf40454089018397a870322c073b55211643861
4
- data.tar.gz: 0374d830df84452815f119d95bdc949edc83631e29f967c33f783ebb4aaaca95
3
+ metadata.gz: b36ce374096906b32edb0f0cbfccca790e437fce074740d40c3b88dc290f504e
4
+ data.tar.gz: 3e8100f10e53407727e9c6f590e209803b971db3c10eb1239d08570950a075e2
5
5
  SHA512:
6
- metadata.gz: 7f81b075382e421cce2f128ccf057872ba19a8d5282b84409119594a0054461eeb41919adaf95f1fe69295e254e2548c71d505e0105fdb36ea7fe1998523acdd
7
- data.tar.gz: aa6119ba79f49279d376b65877d1c56aa8d5d1f5d9222ee6ab2b0775c05def388c6f542f047461186bc39eb9ecd4409bcd0ef1ec228d6fbef91bdf1c204a4e1d
6
+ metadata.gz: 1f3f6213a3990a1f5947b1eb175930b78980e01cc6a33fa4ebcb0d3f2808292e257c7d0801f38dd324328edbb7a3d8d7ffae8fd9818a2457aca210c6189bf629
7
+ data.tar.gz: 9f719638e07cb0b340c9ad62d8629760bfeeb5c190051a6f72753b3c49372ae77656a3bfc8aab1853756f4eb2be195cff6d2fa7fcb56db377cda486bac4ea9a0
@@ -2,16 +2,21 @@
2
2
 
3
3
  module Clocked
4
4
  class Stopwatch
5
+ module Stringable
6
+ def to_s
7
+ [name, "#{elapsed.round(3)}s"].compact.join(": ")
8
+ end
9
+ end
10
+
5
11
  Lap = Struct.new(:name, :start_time, :end_time) do
12
+ include Stringable
13
+
6
14
  def elapsed
7
15
  end_time - start_time
8
16
  end
9
-
10
- def to_s
11
- "#{name}: #{elapsed}s"
12
- end
13
17
  end
14
18
 
19
+ include Stringable
15
20
  attr_reader :name, :laps, :start_time
16
21
 
17
22
  # Create a new stopwatch.
@@ -42,7 +47,7 @@ module Clocked
42
47
  # Generate a string-representation of the stopwatch and any laps.
43
48
  # @return [String]
44
49
  def to_s
45
- text = [name, "#{elapsed}s"].compact.join(": ")
50
+ text = super
46
51
  text += " (#{laps.map(&:to_s).join(", ")})" unless laps.empty?
47
52
  text
48
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Clocked
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clocked
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McDonald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-06 00:00:00.000000000 Z
11
+ date: 2021-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport