QSID 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/QSID.rb +103 -0
- metadata +61 -0
data/lib/QSID.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
class QSID
|
2
|
+
# Timestamp
|
3
|
+
def self.timestamp
|
4
|
+
@timestamp
|
5
|
+
end
|
6
|
+
def self.timestamp=(time)
|
7
|
+
@timestamp = time
|
8
|
+
end
|
9
|
+
# Year
|
10
|
+
def self.year
|
11
|
+
@year
|
12
|
+
end
|
13
|
+
def self.year=(year)
|
14
|
+
@year = year
|
15
|
+
end
|
16
|
+
# Month
|
17
|
+
def self.month
|
18
|
+
@month
|
19
|
+
end
|
20
|
+
def self.month=(month)
|
21
|
+
if month < 10
|
22
|
+
month = "0#{month}"
|
23
|
+
end
|
24
|
+
@month = month
|
25
|
+
end
|
26
|
+
# Day
|
27
|
+
def self.day
|
28
|
+
@day
|
29
|
+
end
|
30
|
+
def self.day=(day)
|
31
|
+
if day < 10
|
32
|
+
day = "0#{day}"
|
33
|
+
end
|
34
|
+
@day = day
|
35
|
+
end
|
36
|
+
# Metadata
|
37
|
+
def self.meta
|
38
|
+
@meta
|
39
|
+
end
|
40
|
+
def self.meta=(meta)
|
41
|
+
@meta = meta
|
42
|
+
end
|
43
|
+
# rand 1
|
44
|
+
def self.rand1
|
45
|
+
@rand1
|
46
|
+
end
|
47
|
+
def self.rand1=(r1)
|
48
|
+
@rand1 = r1
|
49
|
+
end
|
50
|
+
# rand 2
|
51
|
+
def self.rand2
|
52
|
+
@rand2
|
53
|
+
end
|
54
|
+
def self.rand2=(r2)
|
55
|
+
@rand2 = r2
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.id
|
59
|
+
@id
|
60
|
+
end
|
61
|
+
def self.id=(id)
|
62
|
+
@id = id
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
def self.newID
|
68
|
+
self.id = self._makeID
|
69
|
+
puts self.id
|
70
|
+
return self.id
|
71
|
+
end
|
72
|
+
def self._makeID
|
73
|
+
time = Time.now
|
74
|
+
id = ''
|
75
|
+
self.year = time.year.to_i - 2000
|
76
|
+
self.month = time.month
|
77
|
+
self.day = time.day
|
78
|
+
self.timestamp = time.to_i
|
79
|
+
self.meta = self.__genMeta
|
80
|
+
self.rand1 = self.__genRand1
|
81
|
+
self.rand2 = self.__genRand2
|
82
|
+
id = id + "#{self.year}"
|
83
|
+
id = id + "#{self.month}"
|
84
|
+
id = id + "#{self.day}"
|
85
|
+
id = id + "#{self.timestamp}"
|
86
|
+
id = id + "#{self.meta}"
|
87
|
+
id = id + "#{self.rand1}"
|
88
|
+
id = id + "#{self.rand2}"
|
89
|
+
|
90
|
+
return id
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.__genMeta
|
94
|
+
self.meta = 13000
|
95
|
+
return self.meta
|
96
|
+
end
|
97
|
+
def self.__genRand1
|
98
|
+
return rand(999999-100000)
|
99
|
+
end
|
100
|
+
def self.__genRand2
|
101
|
+
return rand(9999-1000)
|
102
|
+
end
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: QSID
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
version: "0.2"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Skylar Schipper
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2012-04-17 00:00:00 -05:00
|
17
|
+
default_executable:
|
18
|
+
dependencies: []
|
19
|
+
|
20
|
+
description: A 32bit integer ID
|
21
|
+
email: ss@schipp.co
|
22
|
+
executables: []
|
23
|
+
|
24
|
+
extensions: []
|
25
|
+
|
26
|
+
extra_rdoc_files: []
|
27
|
+
|
28
|
+
files:
|
29
|
+
- lib/QSID.rb
|
30
|
+
has_rdoc: true
|
31
|
+
homepage: http://qsid.quietsight.com
|
32
|
+
licenses: []
|
33
|
+
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.3.6
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: 32bit QNID
|
60
|
+
test_files: []
|
61
|
+
|