tree_uzuki 0.4.1 → 0.4.2

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/tree/tree_render.rb +21 -19
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e479ff9ef2011dbdbd9e32af736ff736d56659e6f8dc4904be6aa90bd1462954
4
- data.tar.gz: 3a11a45e98d716e693b0206ad26a9cd160c55bf50739686683d8f25804c66277
3
+ metadata.gz: 8da4a73ac0227bdd9312c8bee26eb0f1ccdfa67873018cd2ded5ad4bd6efbcc4
4
+ data.tar.gz: 6002a951e69d5f1d378ecf89508bdd94b9004f6c990a597cf1fc5110f5292bbe
5
5
  SHA512:
6
- metadata.gz: eb1d4de9ad758955c5f44852054c93f36b119fc8ccc69529d53933dc903b23a67261cd9107942b4f4cd08b2feb1c694640e77f5127a5773317586dd4fdb6f7ae
7
- data.tar.gz: f5d9f38dbe226f551173799c7c6350db9d0b46c6f7d2974549b28f12aebcc1cb0e518a49187513394469d8224a01cb46de5d81bc94d47aa4f97b2d70a180625d
6
+ metadata.gz: c4c9268b6927bc608c7489a5411ce5b010b9ff1b4da2d5e260d84e3682bdaa49e263c620a39568b699717c8d51ff108e9165cdfb297d253772e08f7961bd78e1
7
+ data.tar.gz: d76930ce93828361d54da0e68bb09ceaa2731d823fd64bdb77324cf8209489f4f4fe45c504ea77de86ad257a212a0b4ca56523f960776e7e1b797fd145ed7142
@@ -8,28 +8,30 @@ class Tree_render
8
8
  turn = "└── "
9
9
  space = " "
10
10
  tree_data.sort!
11
- tree_data.reverse_each do |i|
12
- leaf_level = i.to_s.count('/') - root.to_s.count('/')
13
- final_hash[tree_data.index(i)] = Array.new
11
+ i = tree_data.length
12
+ loop do i-=1
13
+ break if i == -1
14
+ leaf_level = tree_data[i].to_s.count('/') - root.to_s.count('/')
15
+ final_hash[i] = Array.new
14
16
  if leaf_level == 1
15
- final_hash[tree_data.index(i)] << branch
16
- final_hash[tree_data.index(i)] << File.basename(i)
17
+ final_hash[i] << branch
18
+ final_hash[i] << File.basename(tree_data[i])
17
19
  else
18
- final_hash[tree_data.index(i)] << space
19
- (leaf_level-2).times {final_hash[tree_data.index(i)] << space}
20
- final_hash[tree_data.index(i)] << branch
21
- final_hash[tree_data.index(i)] << File.basename(i)
20
+ final_hash[i] << space
21
+ (leaf_level-2).times {final_hash[i] << space}
22
+ final_hash[i] << branch
23
+ final_hash[i] << File.basename(tree_data[i])
22
24
  end
23
- final_hash.each_with_index do |obj ,index|
24
- next if final_hash[tree_data.index(i)+1] == nil
25
- if final_hash[tree_data.index(i)][index] == space && (final_hash[tree_data.index(i)+1][index] == branch ||
26
- final_hash[tree_data.index(i)+1][index] == pipe ||
27
- final_hash[tree_data.index(i)+1][index] == turn)
28
- final_hash[tree_data.index(i)][index] = pipe
29
- elsif final_hash[tree_data.index(i)][index] == branch && (final_hash[tree_data.index(i)+1][index] != branch &&
30
- final_hash[tree_data.index(i)+1][index] != pipe &&
31
- final_hash[tree_data.index(i)+1][index] != turn)
32
- final_hash[tree_data.index(i)][index] = turn
25
+ for index in (0..final_hash[i].size)
26
+ next if final_hash[i+1] == nil
27
+ if final_hash[i][index] == space && (final_hash[i+1][index] == branch ||
28
+ final_hash[i+1][index] == pipe ||
29
+ final_hash[i+1][index] == turn)
30
+ final_hash[i][index] = pipe
31
+ elsif final_hash[i][index] == branch && (final_hash[i+1][index] != branch &&
32
+ final_hash[i+1][index] != pipe &&
33
+ final_hash[i+1][index] != turn)
34
+ final_hash[i][index] = turn
33
35
  end
34
36
  end
35
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tree_uzuki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunset Uzuki