slicer 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/slicer/slicer.rb +27 -13
- data/lib/slicer/version.rb +1 -1
- metadata +1 -1
data/lib/slicer/slicer.rb
CHANGED
@@ -6,19 +6,34 @@ class Slicer
|
|
6
6
|
# { :general_admission => some_things, :vip => some_other_things }
|
7
7
|
#
|
8
8
|
|
9
|
-
cattr_accessor :
|
10
|
-
@@
|
9
|
+
cattr_accessor :colors
|
10
|
+
@@colors = ["#00B85C",
|
11
|
+
"#00CC66",
|
12
|
+
"#19D175",
|
13
|
+
"#33D685",
|
14
|
+
"#4DDB94",
|
15
|
+
"#66E0A3",
|
16
|
+
"#80E6B2",
|
17
|
+
"#99EBC2",
|
18
|
+
"#B2F0D1",
|
19
|
+
"#CCF5E0",
|
20
|
+
"#E6FAF0",
|
21
|
+
"#0066CC",
|
22
|
+
"#1975D1",
|
23
|
+
"#3385D6",
|
24
|
+
"#4D94DB",
|
25
|
+
"#66A3E0",
|
26
|
+
"#80B2E6",
|
27
|
+
"#99C2EB",
|
28
|
+
"#B2D1F0",
|
29
|
+
"#CCE0F5",
|
30
|
+
"#E6F0FA"]
|
11
31
|
|
12
|
-
|
13
|
-
"#%06x" % hex
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.darker
|
17
|
-
@@color = @@color - 0x111111
|
18
|
-
end
|
32
|
+
@@color_index = 0
|
19
33
|
|
20
|
-
def self.
|
21
|
-
@@
|
34
|
+
def self.pop_color
|
35
|
+
@@color_index = (@@color_index == @@colors.length-1) ? @@color_index = 0 : @@color_index + 1
|
36
|
+
@@colors[@@color_index]
|
22
37
|
end
|
23
38
|
|
24
39
|
def self.slice(root_slice, things, procs, current_depth=0)
|
@@ -30,8 +45,7 @@ class Slicer
|
|
30
45
|
Array.wrap(map.keys).each do |kee|
|
31
46
|
current_slice = Slice.new(kee)
|
32
47
|
if(procs.length == current_depth+1)
|
33
|
-
current_slice.color =
|
34
|
-
lighter
|
48
|
+
current_slice.color = pop_color
|
35
49
|
current_slice.value = map[kee].length
|
36
50
|
end
|
37
51
|
root_slice.children << slice(current_slice, map[kee], procs, current_depth+1)
|
data/lib/slicer/version.rb
CHANGED