typeid 0.2.0 → 0.2.1
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/lib/typeid/uuid.rb +11 -0
- data/lib/typeid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af045f36c25f729104c597aec25af3c3755bee1d163bc22badce8fa85952d7ec
|
4
|
+
data.tar.gz: 8869cf01f856b513c501229d69fe262233934f7a8c886c8703e1c65a3c53692c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f0019bff65125af55cf414d9bd0d5145cdafa1fedc1cbc6cf69b207966c4674a461daba129bc4cf4d9cb021c9f976a5b77b875bb3041ceae561c0cfd48f4941
|
7
|
+
data.tar.gz: 41def5ca6d85fe6a5a5b4133d64b1c47a3c56632564fe2c83d45c8ddeec752e96523738bf1cc9bf615f547afa60149928552cf01593dcc583c3da729dab1e2f6
|
data/lib/typeid/uuid.rb
CHANGED
@@ -53,11 +53,22 @@ class TypeID < String
|
|
53
53
|
super(string)
|
54
54
|
end
|
55
55
|
|
56
|
+
# Returns the +UUID+ encoded as a base32 +String+.
|
57
|
+
#
|
56
58
|
# @return [String]
|
57
59
|
def base32
|
58
60
|
TypeID::UUID::Base32.encode(bytes)
|
59
61
|
end
|
60
62
|
|
63
|
+
# Returns the timestamp of the +UUID+ as milliseconds since the Unix epoch.
|
64
|
+
#
|
65
|
+
# @return [Integer]
|
66
|
+
def timestamp
|
67
|
+
bytes[0..5]
|
68
|
+
.map.with_index { |byte, index| byte << (5 - index) * 8 }
|
69
|
+
.inject(:|)
|
70
|
+
end
|
71
|
+
|
61
72
|
# @return [String]
|
62
73
|
def inspect
|
63
74
|
"#<#{self.class.name} #{to_s}>"
|
data/lib/typeid/version.rb
CHANGED