short-url-creator 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/short-url-creator.rb +7 -2
- metadata +1 -1
data/lib/short-url-creator.rb
CHANGED
@@ -15,6 +15,7 @@ class ShortUrlCreator
|
|
15
15
|
@count = 0
|
16
16
|
@a = Array.new(7, -1)
|
17
17
|
@k = 0
|
18
|
+
@short_url = []
|
18
19
|
end
|
19
20
|
|
20
21
|
def iterate_chars(array_size)
|
@@ -33,13 +34,17 @@ class ShortUrlCreator
|
|
33
34
|
k = a.length
|
34
35
|
if (k > 1)
|
35
36
|
if ((@h[a[k-2]] + @h[a[k-1]]) != '10')
|
36
|
-
|
37
|
+
@short_url << buffer.reverse
|
37
38
|
end
|
38
39
|
else
|
39
|
-
|
40
|
+
@short_url << buffer.reverse
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
44
|
+
def generate(count)
|
45
|
+
get_short_url(count)
|
46
|
+
@short_url.join
|
47
|
+
end
|
43
48
|
def get_short_url(count)
|
44
49
|
if count > @array_size
|
45
50
|
new_count = count - @array_size
|