tree_outline 0.1.0 → 0.1.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 +8 -8
- data/lib/tree_outline.rb +6 -1
- data/lib/tree_outline/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmJkNDM1NzgwZTMwNjAyNTI3YmM0ZjBiZjQ0ZDY5NzllMDJiZmMwNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTdlOTkyMjc3MWMwMDk0OGEzMGIzY2RiYTFhZDc3NDdkODA5OGM5MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWVmNTJmZGYyNzZmNjYzNWE5OTVhMWIxNjZjZDRhNWZkZmI3NmM3NzFhY2Y3
|
10
|
+
N2QzM2NiMDQyMjI5ZDJhYTFmZTRiNjYzODE1MWM5OWNkN2EzYjEwZWViZmUz
|
11
|
+
Mjk5YzAxZWUwMmRiNTlhMDA4NTVjM2Y0YzlhZDVhZmNlNjQyM2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWE1NDc0ODNmYTg2ZTFlZTBkMDRjMjdkOWY5ZWQ5NTViODZmZTRhMjk2MWE0
|
14
|
+
ZDc4NzM4M2U3OTc2ZDBiZTQwYjAwODRiNjNmNWVmNWM4N2ZlMTIwMTgzZTAy
|
15
|
+
YTU2ZjgwNDdjYjQ3MTM1YjYwZTk4NDI1YTZiY2RiOTBmYzA4OTM=
|
data/lib/tree_outline.rb
CHANGED
@@ -29,7 +29,7 @@ class TreeOutline
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def build_lines(node)
|
32
|
-
return [node_label(node)] if
|
32
|
+
return [node_label(node)] if is_leaf?(node)
|
33
33
|
result = node_children(node).map do |c|
|
34
34
|
build_lines(c)
|
35
35
|
end
|
@@ -59,6 +59,11 @@ class TreeOutline
|
|
59
59
|
result
|
60
60
|
end
|
61
61
|
|
62
|
+
def is_leaf?(node)
|
63
|
+
# mind the order of this OR statement, it's important
|
64
|
+
!node.respond_to?(@children_method) || node_children(node).nil? || node_children(node).empty?
|
65
|
+
end
|
66
|
+
|
62
67
|
def node_label(node)
|
63
68
|
node.public_send @label_method
|
64
69
|
end
|
data/lib/tree_outline/version.rb
CHANGED