tnode 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tnode.rb +25 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4d2bec81e531feee7d0b4f36fe36cf632e80a5b018cbd7c778acdab5f6b1772
4
- data.tar.gz: 995db749118d5b650898d17ff94f782d057dafcdfad9ca3de34bb68e865e3f4f
3
+ metadata.gz: 31c82cfdf9d0b03e794553ada962ee3a1bed80421939bcaf455cb5d434c74f26
4
+ data.tar.gz: 329c673910cfe946af01c839e50add3bcbcfc83b2b3b2362876e1cdff7c54f20
5
5
  SHA512:
6
- metadata.gz: 5190e0ecdc939d1c7ae762b7740f75b366824830dfe6f590d0dcc5b2f4c817a4d96d68730168aa297484e224d74f1a86a58ec515f6954bc3a61710c5adbcd436
7
- data.tar.gz: b034d13090db2db904cbb9d22b0011079d2d35e98bcd9b1d121eb1a0d7cf353caec55b917e70b4c3a825aa90bab7d116f23450fc6692031b158e49232250a2de
6
+ metadata.gz: 8c7a9cbe1216ab6db072014ecf6e3e6ad0060b58b7ea49edff99f64ae3fa76538d7f3e1df4c1f4eda2fb236ff869bfe513462aa36601155f0b076275a8ffe02b
7
+ data.tar.gz: dc2aad78d813c103280d2170944535f71da7755293c559ae3f8d8bf8d93d42f5af121474be9c22b069e05f434a83cc62f1af8432bd5b43eb33d06383909d4c8e
data/lib/tnode.rb CHANGED
@@ -54,18 +54,34 @@ class Tnode
54
54
 
55
55
  def print_struct
56
56
  init_trav_links
57
- re_print_struct(0)
57
+ re_print_struct
58
58
  end
59
59
 
60
- def re_print_struct(depth)
61
- print '--'
62
- print data
63
- trav_links.each do |child|
64
- child.re_print_struct(depth + 1)
65
- print ' ' * depth
60
+ # '├── '
61
+ # ''
62
+ # '└── '
63
+ # ' '
64
+ def re_print_struct(depth = 0, prefs = [])
65
+ puts data if depth == 0
66
+
67
+ # prefixes
68
+ trav_links.each_with_index do |child, i|
69
+ prefs.each do |pref|
70
+ print pref
71
+ end
72
+ if i == trav_links.size - 1 # is last?
73
+ prefs.push ' ' unless child.trav_links.empty? # has childs
74
+ print '└── '
75
+ puts child.data
76
+ child.re_print_struct(depth + 1, prefs) unless child.trav_links.empty?
77
+ prefs.pop
78
+ else
79
+ prefs.push '│ ' unless child.trav_links.empty? # has childs
80
+ print '├── '
81
+ puts child.data
82
+ child.re_print_struct(depth + 1, prefs) unless child.trav_links.empty?
83
+ end
66
84
  end
67
- puts
68
- print ' '
69
85
  end
70
86
 
71
87
  def tree_find(key_data)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tnode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rurika Misaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-11 00:00:00.000000000 Z
11
+ date: 2022-06-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: My data structure homework
14
14
  email: goblinmaiden1931@gmail.com